public void JoinRoom(string roomID, PlayerVO playerVO) { //TODO: implement functionality: //send user's data to server //wait for commands from server: //ServerCommand.ADD_PLAYERS //ServerCommand.REMOVE_PLAYERS //ServerCommand.START_GAME //Dictionary<string, string> data = new Dictionary<string, string>(); //data["message"] = "hello server!"; //socket.Connect(); JoinRoomCommandVO commandVO = new JoinRoomCommandVO { roomID = roomID, playerVO = playerVO }; socket.On(ServerCommand.ADD_PLAYERS, OnAddPlayers); socket.On(ServerCommand.START_MATCH, OnStartGame); socket.On(ServerCommand.ROUND_RESULTS, OnRoundResults); string json = JsonUtility.ToJson(commandVO); socket.Emit(ServerCommands.JOIN_ROOM, new JSONObject(json)); }
public void JoinRoom(string roomID, PlayerVO playerVO) { //mock data /*string playersRawData = Resources.Load<TextAsset>("players").text; * Messenger<PlayerVO[]>.Broadcast(ServerCommand.ADD_PLAYERS, dataParser.GetPlayersData(playersRawData)); * * string initialGameData = getRoundDataFromJson(_currentRoundNumber); * Messenger<RoundResultVO[]>.Broadcast(ServerCommand.START_GAME, dataParser.GetRoundResultsData(initialGameData)); * _currentRoundNumber++; */ //TODO: implement functionality: //send user's data to server //wait for commands from server: //ServerCommand.ADD_PLAYERS //ServerCommand.REMOVE_PLAYERS //ServerCommand.START_GAME //Dictionary<string, string> data = new Dictionary<string, string>(); //data["message"] = "hello server!"; //socket.Connect(); JoinRoomCommandVO commandVO = new JoinRoomCommandVO { roomID = name, playerVO = playerVO }; socket.Emit(ServerCommands.JOIN_ROOM, new JSONObject(JsonUtility.ToJson(commandVO))); }