public async void EnterMatchMaker(Dictionary <string, object> options)
    {
        matchRoom = await RoomManager.JoinOrCreate <ShipBuilderState>("MatchMakerRoom", options);

        matchRoom.OnMessage += OnMatchMessage;
        RoomManager.HandleOnEnterMatchMaking();
    }
Esempio n. 2
0
    public async void HandleEnterGame(MatchMakeResponse response)
    {
        if (response == null)
        {
            Dictionary <string, object> options = new Dictionary <string, object>()
            {
                { "token", PlayerPrefs.GetString("token") },
                { "waveRank", PlayerData.CurrentShip().rank - 5 }
            };
            gameRoom = await RoomManager.JoinOrCreate <GameState>("GameRoom", options);

            SetupGameRoomListeners();
        }
        else
        {
            Dictionary <string, string> headers = new Dictionary <string, string>();
            gameRoom = await RoomManager.ConsumeSeatReservation <GameState>(response, headers);

            SetupGameRoomListeners();
        }

        gameRoom.OnLeave += async(code) =>
        {
            Debug.Log("[GameRoom] On Leave: " + code + " : Attempting Reconnect");
            try
            {
                gameRoom = await RoomManager.ReconnectToGame <GameState>(gameRoom.Id, gameRoom.SessionId);

                SetupGameRoomListeners();
                Debug.Log("[GameRoom] Reconnection Success: " + gameRoom.SessionId);
            }
            catch
            {
                Debug.Log("[GameRoom] On Leave: Could not reconnnect");
            }
        };
    }