public static Response parseAllowJoinRoom(MessageBuffer msg) { msg.reset(); Int32 size = msg.popInt(); Int16 action = msg.popShort(); Int16 numPlayers = msg.popShort(); string roomName = msg.popString(); List<string> playerNames = new List<string>(numPlayers); for (int i = 0; i < numPlayers; i++) playerNames.Add(msg.popString()); return new RoomJoinedResponse(roomName, playerNames, numPlayers); }
public static Response parseDenyJoinRoom(MessageBuffer msg) { msg.reset(); Int32 size = msg.popInt(); Int16 action = msg.popShort(); string roomName = msg.popString(); return new RoomNotJoinedResponse(roomName); }
public static Response parseCreateRoom(MessageBuffer msg) { msg.reset(); Int32 size = msg.popInt(); Int16 action = msg.popShort(); Int16 result = msg.popShort(); string roomName = msg.popString(); return new RoomCreatedResponse(result, roomName); }
public static Response parseLeaveRoom(MessageBuffer msg) { msg.reset(); Int32 size = msg.popInt(); Int16 action = msg.popShort(); string userName = msg.popString(); string roomName = msg.popString(); return new PlayerLeftRoomResponse(userName, roomName); }
public static Response parseStartGame(MessageBuffer msg) { msg.reset(); Int32 size = msg.popInt(); Int16 action = msg.popShort(); Int16 numPlayers = msg.popShort(); List<Int16> playerIds = new List<Int16>(numPlayers); for (int i = 0; i < numPlayers; i++) playerIds.Add(msg.popShort()); List<string> playerNames = new List<string>(numPlayers); for (int i = 0; i < numPlayers; i++) playerNames.Add(msg.popString()); string map = msg.popString(); return new StartGameResponse(playerNames, map); }
public static Response parseSendAvailableRooms(MessageBuffer msg) { msg.reset(); Int32 size = msg.popInt(); Int16 action = msg.popShort(); Int16 numRooms = msg.popShort(); List<string> roomNames = new List<string>(numRooms); for (int i = 0; i < numRooms; i++) roomNames.Add(msg.popString()); List<Room> rooms = new List<Room>(numRooms); for (int i = 0; i < numRooms; i++) rooms.Add(new Room(roomNames[i], 2)); return new RoomsAvailableResponse(rooms); }