Subject: Send JSON as Body
Hi,
I develop a chat application and I have to send a JSON as message's body. I can read incoming messages but I can't send if it's not like a String.
If I send my message like
the message can't be read by other application (ignored message)
If I send my message like
my Stream is closed immediatly and the message isn't sent
If the body isn't a String, I can't send it, so I want to know how can I send JSON as Body
Function that sent message
Thanks
I develop a chat application and I have to send a JSON as message's body. I can read incoming messages but I can't send if it's not like a String.
If I send my message like
- <message to="id@server" type="chat" id="123" xmlns="jabber:client">
- <body>"JSONObject"</body>
- </message>
If I send my message like
- <message to="id@server" type="chat" id="123" xmlns="jabber:client">
- <body>JSONObject</body>
- </message>
If the body isn't a String, I can't send it, so I want to know how can I send JSON as Body
Function that sent message
- /*...*/
- using Matrix;
- using Matrix.Xmpp.Client;
- /*...*/
- XmppClient client;
- MyMessage message;
- /*...*/
- /*
- client : Connection, Events ...
- message : create
- */
- private void Send_Click(object sender, RoutedEventArgs e)
- {
- m.To = userId + "@" + server;
- m.Type = Matrix.Xmpp.MessageType.Chat;
- m.Id = Guid.NewGuid().ToString();
- m.Body = message.ToJSON(); //message isn't sent, Stream closed
- //m.Body = "\"" + message.ToJSON() + "\""; //message sent but can't be read by other apps
- m.RequestReceipt();
- client.Send(m);
- }
Thanks