/// <summary>
        ///   Sends a 'SEND' message
        /// </summary>
        public static void Send(this IStompClient client, string message, string destination)
        {
            var stompMsg = new StompMessage("SEND", message);
            stompMsg["destination"] = destination;

            client.OnMessage(stompMsg);
        }
예제 #2
0
        private void GetDeviceList(AppMessage appMessage)
        {
            ArrayList deviceMessages = new ArrayList();
            ArrayList arrayList      = JsonConvert.DeserializeObject <ArrayList>(appMessage.content.ToString());

            foreach (var item in arrayList)
            {
                DeviceMessage deviceMessage = JsonConvert.DeserializeObject <DeviceMessage>(item.ToString());
                deviceMessages.Add(deviceMessage);
            }
            listView1.Items.Clear();
            listView1.Refresh();
            foreach (DeviceMessage deviceMessage in deviceMessages)
            {
                string[] row = { deviceMessage.deviceName, deviceMessage.imei, "Offline" };
                listView1.Items.Add(new ListViewItem(row));
            }
            appMessage         = new AppMessage();
            appMessage.command = "CHECK_ONLINE";

            string json = JsonConvert.SerializeObject(appMessage);

            var broad = new StompMessage("SEND", json);

            broad["content-type"] = "application/json";
            broad["destination"]  = "/app/manager";
            ws.Send(serializer.Serialize(broad));
        }
        /// <summary>
        ///   Sends an 'UNSUBSCRIBE' message
        /// </summary>
        public static void UnSubscribe(this IStompClient client, string destination)
        {
            var stompMsg = new StompMessage("UNSUBSCRIBE");
            stompMsg["destination"] = destination;

            client.OnMessage(stompMsg);
        }
        private void Connect(string command, string username)
        {
            using (var ws = new WebSocket("ws://127.0.0.1:8080/gs-guide-websocket"))
            {
                ws.OnMessage += ws_OnMessage;
                ws.OnOpen    += ws_OnOpen;
                ws.Connect();

                StompMessageSerializer serializer = new StompMessageSerializer();

                var connect = new StompMessage("CONNECT");
                connect["accept-version"] = "1.2";
                connect["host"]           = "";
                ws.Send(serializer.Serialize(connect));

                var content = new Content()
                {
                    Username = username, Message = command, id = Guid.NewGuid()
                };
                var broad = new StompMessage("SEND", JsonConvert.SerializeObject(content));
                broad["content-type"] = "application/json";
                broad["destination"]  = "/client/message";
                ws.Send(serializer.Serialize(broad));

                Console.ReadKey(true);
            }
        }
예제 #5
0
        //Arkadaşla Oynamak İçin
        public void SendRegisterWithFriend()
        {
            var content = new SoketSendRegisterDTO()
            {
                category          = OyunSocketHelper_Helper.SecilenAlan,//SAY SOZ EA
                userName          = MeId.login,
                userQuestionIndex = "0",
                userToken         = MeId.API_TOKEN,
                filters           = GetLessonsForAlan(),
                friendsUser       = ArkadasOyunSec_Gonderen_Helper.SecilenKisi.login,
                isFriend          = true,
                startTime         = DateTime.Now.ToString()
            };
            var broad = new StompMessage(StompFrame.SEND, JsonConvert.SerializeObject(content));

            broad["content-type"] = "application/json";
            // broad["username"] = MeId.login;
            broad["destination"] = "/app/requestFriend";
            var aaa = serializer.Serialize(broad);

            if (ws.IsAlive)
            {
                ws.Send(aaa);
            }
        }
예제 #6
0
 /// <summary>
 /// Sends a message to the client
 /// </summary>
 /// <param name="message"></param>
 public void Send(StompMessage message)
 {
     if (OnServerMessage != null)
     {
         OnServerMessage(message);
     }
 }
        void GuncellemeGonderSoket()
        {
            var ToplamCozumSayisi = OyunSocketHelper_Helper.RoomQuestionsDTO1.questionList.FindAll(item => !string.IsNullOrEmpty(item.userAnswer)).Count;

            if (ToplamCozumSayisi > 0)
            {
                TestSinavAlaniHelperClass.OyunSinavAlaniBaseActivity1.BenGuncelle(ToplamCozumSayisi);//Lokal UI güncelle

                var content = new SoketSendRegisterDTO()
                {
                    category          = OyunSocketHelper_Helper.SecilenAlan,
                    userName          = MeId.login,
                    userQuestionIndex = ToplamCozumSayisi.ToString(),
                    userToken         = MeId.API_TOKEN,
                    filters           = new List <string>(),
                };

                var broad = new StompMessage(StompFrame.SEND, JsonConvert.SerializeObject(content));
                broad["content-type"] = "application/json";
                // broad["username"] = MeId.login;
                broad["destination"] = "/app/level";
                var aaa = OyunSocketHelper_Helper.OyunSocketHelper1.serializer.Serialize(broad);
                if (OyunSocketHelper_Helper.OyunSocketHelper1.ws.IsAlive)
                {
                    OyunSocketHelper_Helper.OyunSocketHelper1.ws.Send(aaa);
                }
            }
        }
예제 #8
0
        void Ws_OnMessage(object sender, MessageEventArgs e)
        {
            this.BeginInvoke((Action) delegate()
            {
                StompMessage msg = serializer.Deserialize(e.Data);
                if (msg.Command == "MESSAGE")
                {
                    AppMessage appMessage = JsonConvert.DeserializeObject <AppMessage>(msg.Body);
                    string command        = appMessage.command;
                    switch (command)
                    {
                    case "GET_DEVICE_LIST":
                        GetDeviceList(appMessage);
                        break;

                    case "DEVICE_ONLINE":
                        SetDeviceOnline(appMessage);
                        break;

                    case "LOCATION_UPDATED":
                        LocationUpdated(appMessage);
                        break;

                    case "UPDATE_INFO":
                        UpdateInfo(appMessage);
                        break;
                    }
                }
            });
        }
예제 #9
0
 private void ThrowOnErrorStompMessage(StompMessage message)
 {
     if (message.IsError())
     {
         throw new IssPlusWebSocketClientException("STOMP ERROR message");
     }
 }
        void OyunuBitir()
        {
            var ToplamCozumSayisi = OyunSocketHelper_Helper.RoomQuestionsDTO1.questionList.FindAll(item => !string.IsNullOrEmpty(item.userAnswer)).Count;

            var content = new SoketSendRegisterDTO()
            {
                category          = "",
                userName          = Me.login,
                userQuestionIndex = "0",
                userToken         = Me.API_TOKEN,
                filters           = new List <string>(),
                correctCount      = ToplamDogruSayisiDon(),
                questionCount     = OyunSocketHelper_Helper.RoomQuestionsDTO1.questionList.Count
            };

            var broad = new StompMessage(StompFrame.SEND, JsonConvert.SerializeObject(content));

            broad["content-type"] = "application/json";
            // broad["username"] = MeId.login;
            broad["destination"] = "/app/end";
            var aaa = OyunSocketHelper_Helper.OyunSocketHelper1.serializer.Serialize(broad);

            if (OyunSocketHelper_Helper.OyunSocketHelper1.ws.IsAlive)
            {
                OyunSocketHelper_Helper.OyunSocketHelper1.ws.Send(aaa);
            }
        }
예제 #11
0
        /// <summary>
        /// 订阅消息
        /// </summary>
        private void SubscribeStomp()
        {
            //

            var sub_test = new StompMessage(StompFrame.SUBSCRIBE);

            //unique Key per subscription
            sub_test["id"]          = "sub-0";
            sub_test["destination"] = "/topic/latest_quotation_detail_CL1906";
            webSocket.Send(serializer.Serialize(sub_test));

            //var sub = new StompMessage(StompFrame.SUBSCRIBE);
            ////unique Key per subscription
            //sub["id"] = "sub-0";
            //sub["destination"] = "/topic/latest_quotation_detail_CL1906";
            //webSocket.Send(serializer.Serialize(sub));

            //var sub1 = new StompMessage(StompFrame.SUBSCRIBE);
            ////unique Key per subscription
            //sub1["id"] = "sub-1";
            //sub1["a"] = "/topic/ask_bid_CL1906";
            //webSocket.Send(serializer.Serialize(sub1));

            foreach (var item in destinations)
            {
                var sub = new StompMessage(StompFrame.SUBSCRIBE);
                sub["id"]          = item.Key;
                sub["destination"] = item.Value;
                webSocket.Send(serializer.Serialize(sub));
            }
        }
예제 #12
0
        private void Connect(User user, WebSocket webSocket)
        {
            webSocket.OnMessage += WebSocketOnMessage;
            webSocket.OnOpen    += WebSocketOnOpen;
            webSocket.OnClose   += WebSocketOnClose;
            webSocket.OnError   += WebSocketOnError;

            webSocket.SetCredentials(user.login, user.password, true);
            webSocket.Connect();

            Console.WriteLine(webSocket.IsAlive);

            var connect = new StompMessage("CONNECT")
            {
                ["accept-version"] = "1.2", ["host"] = ""
            };

            webSocket.Send(Serializer.Serialize(connect));

            var sub = new StompMessage("SUBSCRIBE")
            {
                ["id"] = "sub-0", ["destination"] = "/topic/status"
            };

            webSocket.Send(Serializer.Serialize(sub));

            Thread.Sleep(int.MaxValue);
        }
예제 #13
0
 public void Send(StompMessage message)
 {
     if (OnSend != null)
     {
         OnSend(message);
     }
 }
예제 #14
0
        public void WhenASubscribedClientSendsAMessage_ItShouldBePublishedToAllTheClienstInTheQueue()
        {
            var client1 = _listener.GetASubscribedClient("/test");
            var client2 = _listener.GetASubscribedClient("/test");

            int cnt = 0;

            client1.OnServerMessage = msg => { if (msg.Command == "MESSAGE" && msg.Body == "my body" && msg["destination"] == "/test")
                                               {
                                                   cnt++;
                                               }
            };
            client2.OnServerMessage = msg => { if (msg.Command == "MESSAGE" && msg.Body == "my body" && msg["destination"] == "/test")
                                               {
                                                   cnt++;
                                               }
            };

            var message = new StompMessage("SEND", "my body");

            message["destination"] = "/test";
            client1.OnMessage(message);

            Assert.AreEqual(cnt, 2);
        }
 public StompWebsocketHandler send(StompMessage sMessage)
 {
     Debug.Log(responseDestination);
     toSendMessages.Enqueue(sMessage);
     sendToSendMessages();
     return(this);
 }
예제 #16
0
 public Form1()
 {
     InitializeComponent();
     client             = new StompClient("127.0.0.1", 12345);
     client.OnReceived += Client_OnReceived;
     toSend             = new StompMessage();
     connected          = false;
 }
        /// <summary>
        ///   Sends an 'UNSUBSCRIBE' message
        /// </summary>
        public static void UnSubscribe(this IStompClient client, string destination)
        {
            var stompMsg = new StompMessage("UNSUBSCRIBE");

            stompMsg["destination"] = destination;

            client.OnMessage(stompMsg);
        }
        /// <summary>
        ///   Sends a 'SEND' message
        /// </summary>
        public static void Send(this IStompClient client, string message, string destination)
        {
            var stompMsg = new StompMessage("SEND", message);

            stompMsg["destination"] = destination;

            client.OnMessage(stompMsg);
        }
예제 #19
0
        private async Task Unsubscribe(string id)
        {
            var message = new StompMessage(StompMessageCommand.UNSUBSCRIBE, new Headers
            {
                [StompMessageHeader.Id] = id
            });

            await SendMessage(message);
        }
예제 #20
0
        /// <summary>
        /// 连接
        /// </summary>
        public void Connect(Action <string> onMessage)
        {
            this.onMessage = onMessage;
            var connect = new StompMessage(StompFrame.CONNECT);

            connect["accept-version"] = "1.1";
            connect["host"]           = "";
            connect["heart-beat"]     = "0,0";
            webSocket.Send(serializer.Serialize(connect));
        }
        public void SerializingAStompMessage()
        {
            var msg = new StompMessage("CONNECT", "lorum!");
            msg["destination"] = "/my/queue";
            msg["foo"] = "bar";

            string r = new StompMessageSerializer().Serialize(msg);

            Assert.AreEqual(r, "CONNECT\ncontent-length:6\ndestination:/my/queue\nfoo:bar\n\nlorum!\0");
        }
예제 #22
0
 /// <summary>
 ///   Unsubscribes the specified destination.
 /// </summary>
 /// <param name = "destination">The destination.</param>
 public void Unsubscribe(string destination)
 {
     ExecuteWhenConnected(
         () =>
     {
         var msg            = new StompMessage("UNSUBSCRIBE");
         msg["destination"] = destination;
         _transport.Send(_serializer.Serialize(msg));
     });
 }
예제 #23
0
        /// <summary>
        ///   Called when [connected] received.
        /// </summary>
        /// <param name = "obj">The obj.</param>
        private void OnStompConnected(StompMessage obj)
        {
            IsConnected = true;

            foreach (var action in _commandQueue)
            {
                action();
            }

            _commandQueue.Clear();
        }
예제 #24
0
        private void ConnectStomp()
        {
            var connect = new StompMessage(StompFrame.CONNECT);

            connect["accept-version"] = "1.2";
            connect["host"]           = "";
            // first number Zero mean client not able to send Heartbeat,
            //Second number mean Server will sending heartbeat to client instead
            connect["heart-beat"] = "0,10000";
            ws.Send(serializer.Serialize(connect));
        }
예제 #25
0
        public void SerializingAStompMessage()
        {
            var msg = new StompMessage("CONNECT", "lorum!");

            msg["destination"] = "/my/queue";
            msg["foo"]         = "bar";

            string r = new StompMessageSerializer().Serialize(msg);

            Assert.AreEqual(r, "CONNECT\ncontent-length:6\ndestination:/my/queue\nfoo:bar\n\nlorum!\0");
        }
예제 #26
0
        private void button2_Click(object sender, EventArgs e)
        {
            var content = new Content()
            {
                Subject = "Stomp client", Message = "Hello World!!"
            };
            var broad = new StompMessage(StompFrame.SEND, JsonConvert.SerializeObject(content));

            broad["content-type"] = "application/json";
            broad["destination"]  = "/queue/message-" + txtTarget.Text;
            ws.Send(serializer.Serialize(broad));
        }
예제 #27
0
        public static MockClient GetASubscribedClient(this IStompListener listener, string queue, string subscriptionId)
        {
            var client = listener.GetAConnectedClient();

            var message = new StompMessage("SUBSCRIBE");
            message["destination"] = queue;
            message["id"] = subscriptionId;

            client.OnMessage(message);

            return client;
        }
예제 #28
0
        private void WebSocketOnMessage(object sender, MessageEventArgs e)
        {
            try
            {
                var deserializedStompMessage = Serializer.Deserialize(e.Data);
                var stompMessageBody         = deserializedStompMessage.Body;


                if (stompMessageBody.Contains("ping"))
                {
                    Console.WriteLine($"---------------\n{DateTime.Now}: Got ping!");
                    UserSocketPairs.TryGetValue(_user, out var webSocket);
                    var pingAnswer = new StompMessage("MESSAGE", "answer")
                    {
                        ["destination"] = "/topic/status", ["message-id"] = messageId++.ToString(), ["content-type"] = "text/plain"
                    };
                    webSocket.Send(Serializer.Serialize(pingAnswer));
                    return;
                }

                if (stompMessageBody.Contains("answer"))
                {
                    Console.WriteLine($"---------------\n{DateTime.Now}: Answer sent!");
                    return;
                }

                Console.WriteLine($"---------------\n{DateTime.Now}\nUser [{_user.chatId}]:\n{e.Data}");

                if (!stompMessageBody.IsNullOrEmpty())
                {
                    try
                    {
                        var json = JsonConvert.DeserializeObject <VideoJson>(stompMessageBody);
                        TomBot.BotClient.SendTextMessageAsync(_user.chatId, $"Vod ID: {json.vodId}\n" +
                                                              $"Date: {json.date}\n" +
                                                              $"UUID: {json.uuid}\n" +
                                                              $"Started by: {json.startedBy}\n" +
                                                              $"State: {json.state}\n" +
                                                              $"twitch.tv/videos/{json.vodId}");
                    }

                    catch (JsonReaderException)
                    {
                    }
                }
            }

            catch (Exception exception)
            {
                Console.WriteLine(exception);
            }
        }
예제 #29
0
        public static MockClient GetASubscribedClient(this IStompListener listener, string queue, string subscriptionId)
        {
            var client = listener.GetAConnectedClient();

            var message = new StompMessage("SUBSCRIBE");

            message["destination"] = queue;
            message["id"]          = subscriptionId;

            client.OnMessage(message);

            return(client);
        }
예제 #30
0
        public void WhenTheLastClientUnSubscribs_TheQueueShouldBeRemoved()
        {
            var client = _listener.GetASubscribedClient("/test");

            Assert.IsNotEmpty(_server.Queues);

            var message = new StompMessage("UNSUBSCRIBE");

            message["destination"] = "/test";
            client.OnMessage(message);

            Assert.IsEmpty(_server.Queues);
        }
예제 #31
0
        /// <summary>
        ///   Dispatches the given message to a registerd message consumer.
        /// </summary>
        /// <param name = "message">The message.</param>
        private void HandleMessage(StompMessage message)
        {
            if (message == null || message.Command == null)
            {
                return;
            }
            if (!_messageConsumers.ContainsKey(message.Command))
            {
                return;
            }

            _messageConsumers[message.Command](message);
        }
예제 #32
0
        /// <summary>
        ///   Disconnects this instance.
        /// </summary>
        public void Disconnect()
        {
            ExecuteWhenConnected(
                () =>
            {
                var msg = new StompMessage("DISCONNECT");
                _transport.Send(_serializer.Serialize(msg));

                _transport.Close();

                IsConnected = false;
            });
        }
예제 #33
0
        public void WhenAClientUnSubscribes_TheClientShouldBeRemovedFromTheQueue()
        {
            var client1 = _listener.GetASubscribedClient("/test");
            var client2 = _listener.GetASubscribedClient("/test");

            var message = new StompMessage("UNSUBSCRIBE");

            message["destination"] = "/test";
            client2.OnMessage(message);

            Assert.That(_server.Queues.First().Clients.Contains(client1));
            Assert.That(_server.Queues.First().Clients.Contains(client2) == false);
        }
예제 #34
0
        private void UpdateLocation(string imei)
        {
            AppMessage appMessage = new AppMessage();

            appMessage.command = "UPDATE_LOCATION";
            appMessage.imei    = imei;

            string json = JsonConvert.SerializeObject(appMessage);

            var broad = new StompMessage("SEND", json);

            broad["content-type"] = "application/json";
            broad["destination"]  = "/app/manager";
            ws.Send(serializer.Serialize(broad));
        }
예제 #35
0
        public void WhenClientIncludedAnIdOnSubscription_TheIdShouldBeInTheMessageResponse()
        {
            var client1 = _listener.GetASubscribedClient("/test", "123");
            var client2 = _listener.GetASubscribedClient("/test", "456");

            var message = new StompMessage("SEND");
            message["destination"] = "/test";

            StompMessage r1 = null;
            client1.OnServerMessage += m => r1 = m;
            StompMessage r2 = null;
            client2.OnServerMessage += m => r2 = m;

            client1.OnMessage(message);

            Assert.AreEqual(r1.Command, "MESSAGE");
            Assert.AreEqual(r1["subscription"], "123");

            Assert.AreEqual(r2.Command, "MESSAGE");
            Assert.AreEqual(r2["subscription"], "456");
        }
예제 #36
0
        public void WhenASubscribedClientSendsAMessage_ItShouldBePublishedToAllTheClienstInTheQueue()
        {
            var client1 = _listener.GetASubscribedClient("/test");
            var client2 = _listener.GetASubscribedClient("/test");

            int cnt = 0;
            client1.OnServerMessage = msg => { if (msg.Command == "MESSAGE" && msg.Body == "my body" && msg["destination"] == "/test") cnt++; };
            client2.OnServerMessage = msg => { if (msg.Command == "MESSAGE" && msg.Body == "my body" && msg["destination"] == "/test") cnt++; };

            var message = new StompMessage("SEND","my body");
            message["destination"] = "/test";
            client1.OnMessage(message);

            Assert.AreEqual(cnt, 2);
        }
예제 #37
0
        public void WhenASubscribedClientSendsAMessageToANonSubscribedQueue_TheMessageShouldBePublished()
        {
            var unsubscribedClient = _listener.GetAConnectedClient();
            var client = _listener.GetASubscribedClient("/test");

            var message = new StompMessage("SEND","Hi, you don't know me but...");
            message["destination"] = "/test";

            StompMessage r = null;
            client.OnServerMessage += m => r = m;

            unsubscribedClient.OnMessage(message);

            Assert.That(_server.Queues.First().Clients.Contains(client));

            Assert.NotNull(r);
            Assert.AreEqual(r.Command, "MESSAGE");
            Assert.AreEqual(r.Body, "Hi, you don't know me but...");
        }
예제 #38
0
        public void WhenAClientUnSubscribes_TheClientShouldBeRemovedFromTheQueue()
        {
            var client1 = _listener.GetASubscribedClient("/test");
            var client2 = _listener.GetASubscribedClient("/test");

            var message = new StompMessage("UNSUBSCRIBE");
            message["destination"] = "/test";
            client2.OnMessage(message);

            Assert.That(_server.Queues.First().Clients.Contains(client1));
            Assert.That(_server.Queues.First().Clients.Contains(client2) == false);
        }
예제 #39
0
        public void WhenAClientUnSubscribesFromAnInValidQueue_AnErrorShouldBeReturned()
        {
            var client = _listener.GetASubscribedClient("/test");

            var message = new StompMessage("UNSUBSCRIBE");
            message["destination"] = "/test2";

            StompMessage r = null;
            client.OnServerMessage += m => r = m;
            client.OnMessage(message);

            Assert.That(_server.Queues.First().Clients.Contains(client));

            Assert.NotNull(r);
            Assert.AreEqual(r.Command,"ERROR");
            Assert.AreEqual(r.Body, "You are not subscribed to queue '/test2'");
        }
예제 #40
0
        /// <summary>
        ///   Dispatches the given message to a registerd message consumer.
        /// </summary>
        /// <param name = "message">The message.</param>
        private void HandleMessage(StompMessage message)
        {
            if (message == null || message.Command == null) return;
            if (!_messageConsumers.ContainsKey(message.Command)) return;

            _messageConsumers[message.Command](message);
        }
예제 #41
0
 /// <summary>
 /// Sends a message to the client
 /// </summary>
 /// <param name="message"></param>
 public void Send(StompMessage message)
 {
     if (OnServerMessage != null)
         OnServerMessage(message);
 }
예제 #42
0
        public void WhenAClientSubscribesToANonExistingQueue_TheQueueShouldBeCreatedAndTheClientShouldBeAdded()
        {
            var client = _listener.GetAConnectedClient();

            var message = new StompMessage("SUBSCRIBE");
            message["destination"] = "/queue/test";

            Assert.IsEmpty(_server.Queues);

            client.OnMessage(message);

            Assert.IsNotEmpty(_server.Queues);
            Assert.That(_server.Queues.First().Address.Equals("/queue/test"));
            Assert.That(_server.Queues.First().Clients.Contains(client));
        }
예제 #43
0
        /// <summary>
        ///   Sends a message to the specified address.
        /// </summary>
        /// <param name = "address">The address.</param>
        /// <param name = "message">The message.</param>
        /// <param name = "receiptId">The receipt id.</param>
        public void Send(string address, string message, string receiptId)
        {
            ExecuteWhenConnected(
                () =>
                    {
                        if (address.StartsWith("/") == false) address = string.Format("/{0}", address);

                        var msg = new StompMessage("SEND", message);
                        msg["destination"] = address;
                        msg["id"] = Guid.NewGuid().ToString();

                        if (!string.IsNullOrEmpty(receiptId))
                            msg["receipt"] = receiptId;

                        _transport.Send(_serializer.Serialize(msg));
                    });
        }
예제 #44
0
        public void WhenRequestingAReceipt_AReceiptFrameShouldBeReturned()
        {
            var client = _listener.GetAConnectedClient();

            var message = new StompMessage("SUBSCRIBE");
            message["destination"] = "/test";
            message["receipt"] = "message-12345";

            StompMessage r = null;
            client.OnServerMessage += x => r = x;
            client.OnMessage(message);

            Assert.IsNotNull(r);
            Assert.AreEqual(r.Command,"RECEIPT");
            Assert.AreEqual(r["receipt-id"], "message-12345");
        }
예제 #45
0
        /// <summary>
        ///   Called when [connected] received.
        /// </summary>
        /// <param name = "obj">The obj.</param>
        private void OnStompConnected(StompMessage obj)
        {
            IsConnected = true;

            foreach (var action in _commandQueue)
            {
                action();
            }

            _commandQueue.Clear();
        }
예제 #46
0
        public void WhenTheLastClientUnSubscribs_TheQueueShouldBeRemoved()
        {
            var client = _listener.GetASubscribedClient("/test");

            Assert.IsNotEmpty(_server.Queues);

            var message = new StompMessage("UNSUBSCRIBE");
            message["destination"] = "/test";
            client.OnMessage(message);

            Assert.IsEmpty(_server.Queues);
        }
예제 #47
0
 /// <summary>
 ///   Unsubscribes the specified destination.
 /// </summary>
 /// <param name = "destination">The destination.</param>
 public void Unsubscribe(string destination)
 {
     ExecuteWhenConnected(
         () =>
             {
                 var msg = new StompMessage("UNSUBSCRIBE");
                 msg["destination"] = destination;
                 _transport.Send(_serializer.Serialize(msg));
             });
 }
        /// <summary>
        ///   Sends a 'CONNECT' message
        /// </summary>
        public static void Connect(this IStompClient client)
        {
            var stompMsg = new StompMessage("CONNECT");

            client.OnMessage(stompMsg);
        }
예제 #49
0
 /// <summary>
 ///   Sends a message to the client
 /// </summary>
 /// <param name = "message"></param>
 public void Send(StompMessage message)
 {
     _socket.Send(_messageSerializer.Serialize(message));
 }
예제 #50
0
 public void Send(StompMessage message)
 {
     if (OnSend != null) OnSend(message);
 }
예제 #51
0
        /// <summary>
        ///   Disconnects this instance.
        /// </summary>
        public void Disconnect()
        {
            ExecuteWhenConnected(
                () =>
                    {
                        var msg = new StompMessage("DISCONNECT");
                        _transport.Send(_serializer.Serialize(msg));

                        _transport.Close();

                        IsConnected = false;
                    });
        }