Example #1
0
    void Update()
    {
        var packets = Net.doUpdate();

        foreach (var packet in packets)
        {
            // matchmaking was success - receiving match ID and starting a Game
            if (packet.messageType == MessageType.StartTheGame)
            {
                Net.myMatchID = int.Parse(Serializator.DeserializeString(packet.data));
                Net.joinGame();
                SceneManager.LoadScene("Game");
            }
            // receiving response from server and my lobby ID, notifying that I have connected
            else if (packet.messageType == MessageType.SendingLobbyID)
            {
                Net.myLobbyID          = Serializator.DeserializeString(packet.data);
                Net.isConnectedToLobby = true;
            }
        }
    }