Windows Phone 8 XMPP Send and Receive Message






4.83/5 (4 votes)
Send and receive XMPP messages in Windows phone 8
Introduction
This tip tells you about sending and receiving XMPP message in Windows phone 8.
Background
This is continued from my previous article. Please, find the link here.
Using the Code
Sending XMPP message in Windows phone 8 does not require any analysis because it is a method built in with XMPP Client of the DLL.
Below is the syntax required to be followed for sending message.
private void SendXmppMessage(String Message, JId ReceiverJid)
{
ObjXmppClient.SendChatMessage(Message.Trim(), ReceiverJid);
}
But to receive a message from other roster requires handler to initiate the message receiving asynchronously. The handler is OnNewConversationItem
.
The syntax is mentioned below:
ObjXmppClient.OnNewConversationItem += ObjXmppClient_OnNewConversationItem;
void ObjXmppClient_OnNewConversationItem(RosterItem item, bool bReceived,TextMessage msg)
{
if (bReceived)
{
//do your property settings
}
}
If bReceived ==true
, then message is received from other roster, or else message is sent by you to other roster.
Note: I am working on a sample to send and receive files. I will update it soon.
I hope it will be helpful for those who need it.