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); }
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); }
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); }
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); }