protected override void initHandlers() { apiRouter = new Connect4APIRouter(); connectionToServer.RegisterHandler((short)CommProtocol.MsgType.boardUpdate, requestMove); connectionToServer.RegisterHandler((short)CommProtocol.MsgType.playerInit, initSettings); connectionToServer.RegisterHandler((short)CommProtocol.MsgType.RPCMove, handleRPCMove); connectionToServer.RegisterHandler((short)CommProtocol.MsgType.gameInfo, handleGameStatus); connectionToServer.RegisterHandler((short)ServerCommProtocl.PlayerJoinedGameRoom, handlePlayerJoinedRoom); connectionToServer.RegisterHandler((short)ServerCommProtocl.PlayerLeftGameRoom, handlePlayerLeftRoom); connectionToServer.RegisterHandler((short)ServerCommProtocl.PlayerTimerInit, handlePlayerTimerInit); connectionToServer.RegisterHandler((short)ServerCommProtocl.PlayerTimerCommand, handlePlayerTimerCommand); StartCoroutine(findAndInitRenderer <Renderer>((x) => localRenderer = x)); StartCoroutine(handleNetworkMsgQueue()); //Quick hack humanControlls = localRenderer.gameObject.GetComponent <Connect4HumanControlls>(); humanControlls.init((move) => { onOutgoingLocalMsg(move.ToString(), ClientPlayersHandler.sendFromCurrentPlayer()); humanControlls.endPlayerTurn(); }); if (ClientPlayersHandler.hasLocalHumanPlayer()) { ClientPlayersHandler.getLocalHumanPlayer().onHumanTakeInput = () => { humanControlls.startPlayerTurn(); } } ; TCPMessageQueue.readMsgInstant = ((msg) => { TCPMessageQueue.popMessage(); readTCPMsg(msg); }); }
private void checkTCPInput() { if (readTCPInput == null) { return; } while (TCPMessageQueue.hasUnread) { ReceivedLocalMessage m = TCPMessageQueue.popMessage(); readTCPInput(m.message); } }