Simple IQ creation and send Message Example #115
Answered
by
vitalyster
ruicaramalho
asked this question in
Q&A
Replies: 3 comments 6 replies
|
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="servicos@omy.xmmp.pt/RUI-PC" to="rui@my.xmmp.pt" 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="servicos@my.xmmp.pt/RUI-PC" p1:to="rui@my.xmmp.pt" 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 |
1 reply
|
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Where can I find a simple example of creating a message to send?
All reactions