Esempio n. 1
0
        public void LeaveTopic()
        {
            ManualResetEvent evt   = new ManualResetEvent(false);
            INError          error = null;

            var message = new NTopicJoinMessage.Builder().TopicRoom("test-room").Build();

            client1.Send(message, (INResultSet <INTopic> topics) =>
            {
                var topic = topics.Results[0];
                client1.Send(NTopicLeaveMessage.Default(topic.Topic), (bool complete) =>
                {
                    evt.Set();
                }, (INError err) => {
                    error = err;
                    evt.Set();
                });
            }, (INError err) =>
            {
                error = err;
                evt.Set();
            });

            evt.WaitOne(5000, false);
            Assert.IsNull(error);
        }
Esempio n. 2
0
        public void LeaveTopic()
        {
            ManualResetEvent evt   = new ManualResetEvent(false);
            INError          error = null;

            var message = new NTopicJoinMessage.Builder().TopicRoom(Encoding.UTF8.GetBytes("test-room")).Build();

            client1.Send(message, (INTopic topic) =>
            {
                client1.Send(NTopicLeaveMessage.Default(topic.Topic), (bool complete) =>
                {
                    evt.Set();
                }, (INError err) => {
                    error = err;
                    evt.Set();
                });
            }, (INError err) =>
            {
                error = err;
                evt.Set();
            });

            evt.WaitOne(5000, false);
            Assert.IsNull(error);
        }
    public void LeaveRoom()
    {
        client = NakamaData.Singleton.Client;
        ManualResetEvent leaveEvent = new ManualResetEvent(false);

        var message = new NTopicJoinMessage.Builder().TopicRoom(Encoding.UTF8.GetBytes(currentRoom)).Build();

        client.Send(message, (INTopic topic) =>
        {
            client.Send(NTopicLeaveMessage.Default(topic.Topic), (bool complete) =>
            {
                leaveEvent.Set();
            }, (INError err) => {
                Debug.Log("Failed to complete leaving of room : " + err);
                leaveEvent.Set();
            });
        }, (INError err) =>
        {
            Debug.Log("Failed to leave room : " + err);
            leaveEvent.Set();
        });

        leaveEvent.WaitOne(1000, false);
        chatText.Clear();
        currentChatUsers.Clear();
        //chatUsersJoinedID.Clear();
        currentRoom = "";

        UnRegisterOnTopicMessagePresence();
    }
Esempio n. 4
0
        public void PresenceUpdateLeaveTopic()
        {
            INError error = null;

            ManualResetEvent evt1 = new ManualResetEvent(false);

            byte[]  room  = Encoding.UTF8.GetBytes("test-room");
            INTopic topic = null;

            client1.Send(new NTopicJoinMessage.Builder().TopicRoom(room).Build(), (INTopic topic1) =>
            {
                topic = topic1;
                client2.Send(new NTopicJoinMessage.Builder().TopicRoom(room).Build(), (INTopic topic2) =>
                {
                    evt1.Set();
                }, (INError err) =>
                {
                    error = err;
                    evt1.Set();
                });
            }, (INError err) =>
            {
                error = err;
                evt1.Set();
            });
            evt1.WaitOne(5000, false);
            Assert.IsNull(error);
            Assert.IsNotNull(topic);

            byte[]           leaveUserId = null;
            ManualResetEvent evt2        = new ManualResetEvent(false);

            client1.OnTopicPresence += (object source, NTopicPresenceEventArgs args) =>
            {
                leaveUserId = args.TopicPresence.Leave[0].UserId;
                evt2.Set();
            };
            client2.Send(NTopicLeaveMessage.Default(topic.Topic), (bool complete) =>
            {
                // No action.
            }, (INError err) =>
            {
                error = err;
                evt2.Set();
            });

            evt2.WaitOne(5000, false);
            Assert.IsNull(error);
            Assert.AreEqual(userId2, leaveUserId);
        }
Esempio n. 5
0
        public void PresenceUpdateLeaveTopic()
        {
            INError error = null;

            ManualResetEvent evt1  = new ManualResetEvent(false);
            string           room  = "test-room";
            INTopic          topic = null;

            client1.Send(new NTopicJoinMessage.Builder().TopicRoom(room).Build(), (INResultSet <INTopic> topics1) =>
            {
                topic = topics1.Results[0];
                client2.Send(new NTopicJoinMessage.Builder().TopicRoom(room).Build(), (INResultSet <INTopic> topics2) =>
                {
                    evt1.Set();
                }, (INError err) =>
                {
                    error = err;
                    evt1.Set();
                });
            }, (INError err) =>
            {
                error = err;
                evt1.Set();
            });
            evt1.WaitOne(5000, false);
            Assert.IsNull(error);
            Assert.IsNotNull(topic);

            string           leaveUserId = null;
            ManualResetEvent evt2        = new ManualResetEvent(false);

            client1.OnTopicPresence = (INTopicPresence presence) =>
            {
                leaveUserId = presence.Leave[0].UserId;
                evt2.Set();
            };
            client2.Send(NTopicLeaveMessage.Default(topic.Topic), (bool complete) =>
            {
                // No action.
            }, (INError err) =>
            {
                error = err;
                evt2.Set();
            });

            evt2.WaitOne(5000, false);
            Assert.IsNull(error);
            Assert.AreEqual(userId2, leaveUserId);
        }
Esempio n. 6
0
        public void MessageSendWithoutJoinTopic()
        {
            INError error = null;

            INTopic          topic = null;
            ManualResetEvent evt1  = new ManualResetEvent(false);

            client1.Send(new NTopicJoinMessage.Builder().TopicRoom("test-room").Build(), (INResultSet <INTopic> topics) =>
            {
                topic = topics.Results[0];
                client1.Send(NTopicLeaveMessage.Default(topic.Topic), (bool complete) =>
                {
                    evt1.Set();
                }, (INError err) =>
                {
                    error = err;
                    evt1.Set();
                });
            }, (INError err) =>
            {
                error = err;
                evt1.Set();
            });
            evt1.WaitOne(5000, false);
            Assert.IsNull(error);
            Assert.IsNotNull(topic);

            ManualResetEvent evt2 = new ManualResetEvent(false);

            client1.Send(NTopicMessageSendMessage.Default(topic.Topic, "{\"some\":\"data\"}"), (INTopicMessageAck ack) =>
            {
                evt2.Set();
            }, (INError err) =>
            {
                error = err;
                evt2.Set();
            });
            evt2.WaitOne(5000, false);
            Assert.IsNotNull(error);
        }