コード例 #1
0
 private void OnApplicationQuit()
 {
     if (_session != null)
     {
         _client.Disconnect();
     }
 }
コード例 #2
0
ファイル: Matchmake.cs プロジェクト: arxdsilva/nakama-docs
    void OnApplicationQuit()
    {
        // If no matchmaking active just disconnect.
        if (_matchmakeTicket == null)
        {
            // Lets gracefully disconnect from the server.
            _client.Disconnect();
            return;
        }

        // If matchmaking active stop matchmaking then disconnect.
        var message = NMatchmakeRemoveMessage.Default(_matchmakeTicket);

        _client.Send(message, (bool done) => {
            // The user is now removed from the matchmaker pool.
            Debug.Log("Matchmaking stopped.");

            // Lets gracefully disconnect from the server.
            _client.Disconnect();
        }, (INError error) => {
            Debug.LogErrorFormat("Send error: code '{1}' with '{0}'.", error.Message, error.Code);

            // Lets gracefully disconnect from the server.
            _client.Disconnect();
        });
    }
コード例 #3
0
        private void OnMatchData(INMatchData msg)
        {
            switch (msg.OpCode)
            {
            case 99L:
                // game is full so disconnect
                string userHandle = System.Text.Encoding.UTF8.GetString(msg.Data);
                if (userHandle == self.Handle)
                {
                    client.Disconnect();
                }
                break;

            default:
                nvp_EventManager_scr.INSTANCE.InvokeEvent(GameEvents.OnGameMessageReceived, this, msg);
                break;
            }
        }
コード例 #4
0
    void OnApplicationQuit()
    {
        if (client1Connected)
        {
            client1.Disconnect();
        }

        if (client2Connected)
        {
            client2.Disconnect();
        }
    }
コード例 #5
0
        public void GetServerTime_Valid()
        {
            ManualResetEvent evt        = new ManualResetEvent(false);
            long             serverTime = 0;

            string   id      = TestContext.CurrentContext.Random.GetString();
            INClient client  = NClient.Default(DefaultServerKey);
            var      message = NAuthenticateMessage.Device(id);

            client.Register(message, (INSession session) =>
            {
                client.Connect(session);
                Thread.Sleep(500);
                serverTime = client.ServerTime;
                evt.Set();
            }, (INError _) => {
                evt.Set();
            });

            evt.WaitOne(1000, false);
            Assert.That(serverTime, Is.Not.EqualTo(0));
            client.Disconnect();
        }
コード例 #6
0
        public void Connect_Valid()
        {
            ManualResetEvent evt = new ManualResetEvent(false);
            var connected        = false;

            string   id      = TestContext.CurrentContext.Random.GetString();
            INClient client  = NClient.Default(DefaultServerKey);
            var      message = NAuthenticateMessage.Device(id);

            client.Register(message, (INSession session) =>
            {
                client.Connect(session, (bool _) => {
                    connected = true;
                    evt.Set();
                });
            }, (INError _) => {
                evt.Set();
            });

            evt.WaitOne(500, false);
            Assert.IsTrue(connected);
            client.Disconnect();
        }
コード例 #7
0
ファイル: UserChat.cs プロジェクト: truonglvx/nakama-unity
    void OnApplicationQuit()
    {
        if (client1Connected)
        {
            client1.Disconnect();
        }

        if (client2Connected)
        {
            client2.Disconnect();
        }

        // Release button handlers
        RegisterButtonPlayer1.onClick.RemoveListener(Player1RegisterClick);
        LoginButtonPlayer1.onClick.RemoveListener(Player1LoginClick);
        ConnectPlayer1.onClick.RemoveListener(Player1Connect);
        RegisterButtonPlayer2.onClick.RemoveListener(Player2RegisterClick);
        LoginButtonPlayer2.onClick.RemoveListener(Player2LoginClick);
        ConnectPlayer2.onClick.RemoveListener(Player2Connect);
        JoinTopicPlayer1.onClick.RemoveListener(Player1JoinTopic);
        JoinTopicPlayer2.onClick.RemoveListener(Player2JoinTopic);
        SendChatPlayer1.onClick.RemoveListener(Player1SendChatMessage);
        SendChatPlayer2.onClick.RemoveListener(Player2SendChatMessage);
    }
コード例 #8
0
 public void TearDown()
 {
     client.Disconnect();
 }
コード例 #9
0
ファイル: TopicTest.cs プロジェクト: truonglvx/nakama-unity
 public void TearDown()
 {
     client1.Disconnect();
     client2.Disconnect();
 }
コード例 #10
0
 void OnApplicationQuit()
 {
     client.Disconnect();
 }
コード例 #11
0
 private void OnApplicationQuit()
 {
     _doReconnect = false;
     _client.Disconnect();
 }