Simple IQ creation and send Message Example #115
Answered
by
vitalyster
ruicaramalho
asked this question in
Q&A
Replies: 3 comments 6 replies
-
|
Beta Was this translation helpful? Give feedback.
4 replies
Answer selected by
vitalyster
-
Hi, sry but..
My code bellow var _xmppClient = new SharpXMPP.XmppClient(servjid, pass, false);
XElement xmlSend = new XElement(
"message",
new XAttribute("from", servjid.FullJid),
new XAttribute("to", tojid.FullJid),
new XAttribute("type", "chat"),
new XElement("body", message)
);
Log.Debug(xmlSend.ToString());
/* returning:
<message from="[email protected]/RUI-PC" to="[email protected]" type="chat">
<body>Msg do c#</body>
</message>
*/
var xmlXMsg = new XMPPMessage();
xmlXMsg.SetAttributeValue(XNamespace.Get(Namespaces.JabberClient) + "type", "chat");
xmlXMsg.SetAttributeValue(XNamespace.Get(Namespaces.JabberClient) + "id", servjid.FullJid);
xmlXMsg.SetAttributeValue(XNamespace.Get(Namespaces.JabberClient) + "to", tojid.FullJid);
var body = new XElement(XNamespace.Get(Namespaces.JabberClient) + "body");
body.Value = message;
xmlXMsg.Add(body);
Log.Debug(xmlXMsg.ToString());
/* returning: extra p1??
<message p1:type="chat" p1:id="[email protected]/RUI-PC" p1:to="[email protected]" xmlns:p1="jabber:client" xmlns="jabber:client">
<p1:body>Msg do c#</p1:body>
</message>
*/
_xmppClient.Send(xmlXMsg);
/* Fatal Error:
Exception thrown: 'System.ArgumentNullException' in System.Xml.Linq.dll
System.ArgumentNullException: Value cannot be null.
Parameter name: writer
at System.Xml.Linq.XElement.WriteTo(XmlWriter writer)
at SharpXMPP.XmppTcpConnection.Send(XElement data)
/* Also strange is the XML using your method has a extra ´p1´ is that corect? Thanks |
Beta Was this translation helpful? Give feedback.
1 reply
-
|
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Where can I find a simple example of creating a message to send?
Beta Was this translation helpful? Give feedback.
All reactions