示例#1
0
        public void Unsubscribe(string dst)
        {
            var msg = new StompFrame(ClientCommand.UNSUBSCRIBE);

            msg.AddHead("id", dst + "-" + 0);
            msg.AddHead("destination", dst);

            Enqueue(msg);
            subscribes.Remove(dst);
        }
示例#2
0
        public void Subscribe(string dst, OnMessageHandler handler)
        {
            var msg = new StompFrame(ClientCommand.SUBSCRIBE);

            msg.AddHead("id", dst + "-" + 0);
            msg.AddHead("destination", dst);

            Enqueue(msg);
            subscribes.Add(dst, handler);
        }
示例#3
0
        public void Send(string dst, string content)
        {
            var msg = new StompFrame(ClientCommand.SEND);

            msg.AddHead("destination", dst);
            msg.AddHead("content-length", Encoding.UTF8.GetBytes(content).Length.ToString());
            msg.data = content;

            Enqueue(msg);
        }
示例#4
0
        public void Connect()
        {
            if (client.IsAlive)
            {
                Debug.LogWarning("Stomp client already connected");
                return;
            }
            client.Connect();
            Debug.Log("Websocket connected");

            var msg = new StompFrame(ClientCommand.CONNECT);

            msg.AddHead("accept-version", acceptVersion);
            msg.AddHead("heart-beat", heartBeat);

            client.Send(msg.ToString());

            client.OnMessage += (sender, e) => Distributer(e.Data);
        }