Saturday, 31 January 2015

Windows phone 8 XMPP Send and receive message


Continued from my previous article. Please, find link here.

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.

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.
Else then message is sent by you to other roster.

Note : I am working on sample to send and receive files. I will update it soon.


It looks so simple to receive message now right? If yes , please, post a response or feedback or any update required.

I will be hoping to get good feedback and response.

In my next article, I will help you guys to get chat history from openfire server in Windows Phone 8.

3 comments:

  1. A biblioteca que você usa funciona no WP7?

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete
  3. hai sir,from your code i successfully logged into the server..but i cant send and receive messages..i am new to this
    void ObjXmppClient_OnNewConversationItem(RosterItem item, bool bReceived, TextMessage msg)
    {
    if (bReceived)
    {
    //do your property settings
    }
    }

    here what property setting i have to do? how can i create group caht? please reply me

    ReplyDelete