private void button3_Click(object sender, EventArgs e) { var content = new Content() { id = "1", botip = "ip-address", message = "Hello World!!" }; var broad = new StompMessage("SEND", JsonConvert.SerializeObject(content)); broad["content-type"] = "application/json"; broad["destination"] = "/app/botmessage"; string msg = serializer.Serialize(broad); client.Send(msg); }
/// <summary> /// Serializes the specified message. /// </summary> /// <param name = "message">The message.</param> /// <returns>A serialized version of the given <see cref="StompMessage"/></returns> public string Serialize(StompMessage message) { var buffer = new StringBuilder(); buffer.Append(message.Command + "\n"); if (message.Headers != null) { foreach (var header in message.Headers) { buffer.Append(header.Key + ":" + header.Value + "\n"); } } buffer.Append("\n"); buffer.Append(message.Body); buffer.Append('\0'); return(buffer.ToString()); }