internal void SendGameRequest(string[] myRobots, string myname, UnityAction <List <Robot>, List <Robot>, string, Map> readyCallback) { Messages.StartGameMessage msg = new Messages.StartGameMessage(); msg.myName = myname; msg.myRobots = myRobots; gameReadyCallback = readyCallback; // Send(Messages.START_GAME, msg); }
public static StartGameMessage Decode(byte[] bytes) { StartGameMessage message = null; if (bytes != null) { message = new StartGameMessage(); MemoryStream memoryStream = new MemoryStream(bytes); message.msgId = ReadMessageId(memoryStream); message.convId = ReadMessageId(memoryStream); ReadShort(memoryStream); message.GameId = ReadShort(memoryStream); } return(message); }
public static Message DecodeMessage(byte[] messageByteStream) { MemoryStream memoryStream = new MemoryStream(messageByteStream); Message message = null; ReadMessageId(memoryStream); ReadMessageId(memoryStream); short messageType = ReadShort(memoryStream); try { switch (messageType) { case REQUEST_GAME: message = RequestGameMessage.Decode(messageByteStream); break; case GAME_INFO: message = GameInfoMessage.Decode(messageByteStream); break; case START_GAME: message = StartGameMessage.Decode(messageByteStream); break; case GAME_STATE_UPDATE: message = GameStateUpdateMessage.Decode(messageByteStream); break; case ROLL: message = RollMessage.Decode(messageByteStream); break; case TRADE_REQUEST: message = TradeRequestMessage.Decode(messageByteStream); break; case TRADE_REPLY: message = TradeReplyMessage.Decode(messageByteStream); break; case BUY: message = BuyMessage.Decode(messageByteStream); break; case END_TURN: message = EndTurnMessage.Decode(messageByteStream); break; case END_GAME: message = EndGameMessage.Decode(messageByteStream); break; case ACK: message = AckMessage.Decode(messageByteStream); break; case ERROR: message = ErrorMessage.Decode(messageByteStream); break; default: break; } return(message); } catch { return(null); } }