コード例 #1
0
// -------------------------------------------------------- //
// implementation for BMediaEventLooper
// -------------------------------------------------------- //
void AbstractFileInterfaceNode::HandleEvent(
				const media_timed_event *event,
				bigtime_t lateness,
				bool realTimeEvent)
{
	CALLED();
	switch (event->type) {
		case BTimedEventQueue::B_START:
			HandleStart(event,lateness,realTimeEvent);
			break;
		case BTimedEventQueue::B_SEEK:
			HandleSeek(event,lateness,realTimeEvent);
			break;
		case BTimedEventQueue::B_WARP:
			HandleWarp(event,lateness,realTimeEvent);
			break;
		case BTimedEventQueue::B_STOP:
			HandleStop(event,lateness,realTimeEvent);
			break;
		case BTimedEventQueue::B_HANDLE_BUFFER:
			if (RunState() == BMediaEventLooper::B_STARTED) {
				HandleBuffer(event,lateness,realTimeEvent);
			}
			break;
		case BTimedEventQueue::B_DATA_STATUS:
			HandleDataStatus(event,lateness,realTimeEvent);
			break;
		case BTimedEventQueue::B_PARAMETER:
			HandleParameter(event,lateness,realTimeEvent);
			break;
		default:
			PRINT("  unknown event type: %ld\n",event->type);
			break;
	}
}
コード例 #2
0
ファイル: SoundPlayNode.cpp プロジェクト: mariuz/haiku
void
SoundPlayNode::HandleEvent(const media_timed_event* event, bigtime_t lateness,
	bool realTimeEvent)
{
	CALLED();
	switch (event->type) {
		case BTimedEventQueue::B_START:
			HandleStart(event,lateness,realTimeEvent);
			break;
		case BTimedEventQueue::B_SEEK:
			HandleSeek(event,lateness,realTimeEvent);
			break;
		case BTimedEventQueue::B_WARP:
			HandleWarp(event,lateness,realTimeEvent);
			break;
		case BTimedEventQueue::B_STOP:
			HandleStop(event,lateness,realTimeEvent);
			break;
		case BTimedEventQueue::B_HANDLE_BUFFER:
			// we don't get any buffers
			break;
		case SEND_NEW_BUFFER_EVENT:
			if (RunState() == BMediaEventLooper::B_STARTED)
				SendNewBuffer(event, lateness, realTimeEvent);
			break;
		case BTimedEventQueue::B_DATA_STATUS:
			HandleDataStatus(event,lateness,realTimeEvent);
			break;
		case BTimedEventQueue::B_PARAMETER:
			HandleParameter(event,lateness,realTimeEvent);
			break;
		default:
			fprintf(stderr,"  unknown event type: %li\n", event->type);
			break;
	}
}
コード例 #3
0
void Connection::ProcessSectorServerOpcode(short opcode, short bytes)
{
	unsigned long tick = GetNet7TickCount();
	//LogMessage("<CLIENT> ---> 0x%04x\n", opcode);
    //this can be used to intercept messages from the client
    switch (opcode)
    {
        case ENB_OPCODE_0002_LOGIN:
            g_LoggedIn = true;
            g_ServerMgr->m_SectorConnection = this;
            LogMessage("Sending Login packet - connection active\n");
            g_ServerMgr->m_UDPConnection->SetConnectionActive(true);
            g_ServerMgr->m_UDPClient->SetConnectionActive(true);
            time_debug = 50;
            break;

		case ENB_OPCODE_0006_START_ACK :
			g_ServerMgr->m_UDPConnection->ForwardClientOpcode(opcode, bytes, (char*)m_RecvBuffer);
			if (g_ServerMgr->m_UDPClient->GetSectorID() > 9999 || g_ServerMgr->m_UDPConnection->PreferTCP())
			{
				long player_id = g_ServerMgr->m_UDPClient->PlayerID();
				g_ServerMgr->m_UDPConnection->ForwardClientOpcode(ENB_OPCODE_3008_STARBASE_LOGIN_COMPLETE, sizeof(player_id), (char *) &player_id);
				g_ServerMgr->m_UDPClient->SetLoginComplete(true);
			}
			else
			{
				long player_id = g_ServerMgr->m_UDPClient->PlayerID();
				g_ServerMgr->m_UDPConnection->ForwardClientOpcode(ENB_OPCODE_3004_PLAYER_SHIP_SENT, sizeof(player_id), (char *) &player_id);
				g_ServerMgr->m_UDPConnection->KillTCPConnection();
				g_ServerMgr->m_UDPClient->SetLoginComplete(true);
			}
			LogMessage("Sending StartAck to Server %d\n", *((long *) &m_RecvBuffer[0]) );
			return;
			break;

		case ENB_OPCODE_0014_MOVE :
			break;

		case ENB_OPCODE_0012_TURN :
			//only send one of these per 0.25 secs
			if (tick > (m_Turn_Sent + 250))
			{
				g_ServerMgr->m_UDPConnection->ForwardClientOpcode(opcode, bytes, (char*)m_RecvBuffer);
				m_Turn_Sent = tick;
			}
			return;
			break;

		case ENB_OPCODE_0013_TILT :
			//only send one of these per 0.25 secs
			if (tick > (m_Tilt_Sent + 250))
			{
				g_ServerMgr->m_UDPConnection->ForwardClientOpcode(opcode, bytes, (char*)m_RecvBuffer);
				m_Tilt_Sent = tick;
			}
			return;
			break;

        case ENB_OPCODE_00B9_LOGOFF_REQUEST:
            g_LoggedIn = true;
            //drop through
        case ENB_OPCODE_003A_SERVER_HANDOFF:
            //DumpBuffer(m_RecvBuffer, bytes);
            //LogMessage("Handoff\n", opcode);
            //g_ServerMgr->m_UDPConnection->SetConnectionActive(false);
            //g_ServerMgr->m_UDPClient->SetConnectionActive(false);
            break;

        case ENB_OPCODE_002C_ACTION:
            g_ServerMgr->m_UDPConnection->ForwardClientOpcode(opcode, bytes, (char*)m_RecvBuffer);
            ProcessAction();
            return;
            break;

		case ENB_OPCODE_009F_STARBASE_ROOM_CHANGE :
			HandleStarbaseRoomChange();
			break;

		case ENB_OPCODE_009B_WARP:
			HandleWarp();
			break;

        default:
            //LogMessage("Forwarding opcode to server 0x%04x\n", opcode);
            break;
    }

    //forward the opcode to the server via UDP
    g_ServerMgr->m_UDPConnection->ForwardClientOpcode(opcode, bytes, (char*)m_RecvBuffer);
}
コード例 #4
0
ファイル: move.c プロジェクト: dervish77/adgf
/******************************************************************************
*  HandleKeyPress - handle key press                                          *
******************************************************************************/
void
HandleKeyPress(char key, MyProgram *data)
{
   switch(key)
   {
      case KEY_UP:
      case KEY_DOWN:
      case KEY_LEFT:
      case KEY_RIGHT:
         HandlePlayerMove( key, data );
         break;

      case KEY_FIRE:
         HandleFire( data );
         break;

      case KEY_WARP:
         HandleWarp( data );
         break;

      case KEY_SLAMMER:
         HandleSlammer( data );
         break;

      case KEY_NEWGAME:
         UpdateStatus( "Starting new game", data );
         PopupNewGame( data );
         break;

      case KEY_OPENGAME:
         UpdateStatus( "Loading game", data );
         HandleLoadGame( data );
         break;

      case KEY_SAVEGAME:
         UpdateStatus( "Saving game", data );
         HandleSaveGame( data );
         break;

      case KEY_QUITGAME:
         UpdateStatus( "Quitting game", data );
         PopupQuit();
         break;

      case KEY_EXITGAME:
         exit(0);
         break;

      case KEY_MULTI:
         PopupMultiPlayer( data );
         break;

      case KEY_ANIM:
         ToggleAnim( data );
         break;

      case KEY_INVENTORY:
         PopupInventory( data );
         break;

      default:
         break;
   }

   UpdateScore( data );

   if (data->score.health <= 0)
   {
      PopupGameOver( data );
   }
}