Click here to Skip to main content
15,890,399 members
Articles / Programming Languages / C# 3.5
Tip/Trick

Windows Phone 8 XMPP Send and Receive Message

Rate me:
Please Sign up or sign in to vote.
4.83/5 (4 votes)
16 Feb 2015CPOL 13.6K   6   3
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.

C#
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:

C#
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.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior) Dhruv Compusoft Consultancy Pvt Ltd
India India
Senior MES Developer in TruGlobal Pvt Ltd, Bangalore, India.

My Blog
dotnetkraft.blogspot.in
gnnrao.blogspot.in

Comments and Discussions

 
QuestionIs this works for Windows Phone 8.1 Pin
dsivajagan8-Jun-15 2:52
dsivajagan8-Jun-15 2:52 
GeneralMy vote of 5 Pin
Pradeepkumar patil sonu22-Feb-15 18:58
Pradeepkumar patil sonu22-Feb-15 18:58 
GeneralRe: My vote of 5 Pin
Nandakishore G N22-Feb-15 19:02
professionalNandakishore G N22-Feb-15 19:02 
thank you Pradeep patil.

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.