public void requestGame(long gameId, BaseGameController controller, RunnableDelegate callback) { if (state != SystemControllerStates.Default) throw new InvalidOperationException("Invalid SystemController state, waiting Default, but have : " + state); if (connection.isConnected()) { DataMessage message = new DataMessage(Ids.Services.GAME_RESLOVER, Ids.Actions.GameResolver.START_GAME_REQUEST, userInfo.session); message.createWriter(); message.writerLong(gameId).closeWriter(); state = SystemControllerStates.RequestGame; callbacks[SystemCallbacks.RequestGame] = callback; currentGame = controller; connection.registerDataListener(Ids.Services.GAME_RESLOVER, Ids.Actions.GameResolver.START_GAME_REQUEST, onGameRequestComplete); connection.registerDataListener(Ids.Services.GAME_RESLOVER, Ids.Actions.GameResolver.GAME_STARTED, onGameStarted); connection.registerDataListener(Ids.Services.GAME_RESLOVER, Ids.Actions.GameResolver.GAME_FINISHED, onGameFinished); connection.addMessageToSend(message); } else { Handler.getInstance().postAction(callback, RequestGameResults.ConnectionError); } }