void NetworkLogic::joinRandomRoomReturn(int localPlayerNr, const ExitGames::Common::Hashtable& gameProperties, const ExitGames::Common::Hashtable& playerProperties, int errorCode, const ExitGames::Common::JString& errorString) { PhotonPeer_sendDebugOutput(&mLoadBalancingClient, DEBUG_LEVEL_INFO, L""); if(errorCode) { PhotonPeer_sendDebugOutput(&mLoadBalancingClient, DEBUG_LEVEL_ERRORS, L"%ls", errorString.cstr()); mOutputListener->writeLine(L"opJoinRandomRoom() failed: " + errorString); mStateAccessor.setState(STATE_CONNECTED); if(errorCode==32760){ mOutputListener->writeLine(L"Create room"); opCreateRoom(); } return; } PhotonPeer_sendDebugOutput(&mLoadBalancingClient, DEBUG_LEVEL_INFO, L"localPlayerNr: %d", localPlayerNr); mOutputListener->writeLine(L"game room \"" + mLoadBalancingClient.getCurrentlyJoinedRoom().getName() + "\" has been successfully joined"); mOutputListener->writeLine(L"regularly sending dummy events now"); mStateAccessor.setState(STATE_JOINED); }
void NetworkLogic::run(void) { if(mLastInput == INPUT_EXIT && mStateAccessor.getState() != STATE_DISCONNECTING && mStateAccessor.getState() != STATE_DISCONNECTED) { disconnect(); mStateAccessor.setState(STATE_DISCONNECTING); mOutputListener->writeLine(L"terminating application"); } else { State state = mStateAccessor.getState(); switch(state) { case STATE_INITIALIZED: connect(); mStateAccessor.setState(STATE_CONNECTING); mOutputListener->writeLine(L"connecting"); break; case STATE_CONNECTING: break; // wait for callback case STATE_CONNECTED: switch(mLastInput) { case INPUT_CREATE_GAME: // create Game opCreateRoom(); break; case INPUT_JOIN_RANDOM_GAME: // join Game opJoinRandomRoom(); mStateAccessor.setState(STATE_JOINING); mOutputListener->writeLine(L"joining random game"); break; default: // no or illegal input -> stay waiting for legal input break; } break; case STATE_JOINING: break; // wait for callback case STATE_JOINED: //sendEvent(); switch(mLastInput) { case INPUT_LEAVE_GAME: // leave Game mLoadBalancingClient.opLeaveRoom(); mStateAccessor.setState(STATE_LEAVING); mOutputListener->writeLine(L""); mOutputListener->writeLine(L"leaving game room"); break; default: // no or illegal input -> stay waiting for legal input break; } break; case STATE_LEAVING: break; // wait for callback case STATE_LEFT: mStateAccessor.setState(STATE_CONNECTED); break; case STATE_DISCONNECTING: break; // wait for callback default: break; } } mLastInput = INPUT_NON; mLoadBalancingClient.service(); }