Using XMPP and Openfire Server in Windows Phone 8

Implementing Extensible Messaging and Presence Protocol (XMPP) in Windows phone 8 is really a tough experience. Because, there is no third party library which is for free (there are some libraries which are highly expensive).
 

Background

Project was required with WP8 chat application using Openfire server. After many days of exploration, we found a library which works well in WP8 (** WP8- Windows phone 8) but it lacks documentation and support. I started trial and error with this library. Please find the library link below
 

Pre-Requisites

  •          VS 2012 Express for Mobile Edition/ VS2012 Windows Phone SDK installed or Higher.
  •          Basic Knowledge of XAML,C#
  •          Openfire server installed.

Let’s get going

  1. Open VS2012 -> New project -> Select Windows Phone Template -> Select Default application -> Name it as required (here named it as WP8Xmpp) -> Select target OS version – 8.0 

Step1

Step2

2. Use the DLL which is already built (you can find those in the attached sample application).

(Or use the library link mentioned above download the highlighted files and build in separate application and get the dll).

Step3

3. Refer those library phone.socketserver.dll and phone.xmpp.dll

Step4

4. Login panel UI is shown below

Step5

5.In MainPage.xaml.cs create some properties as shown below.

Properties

6. Look at the sample attached and

(Note :- While passing server name its very difficult to judge instead of IPaddress .

But I learnt using trial and error method is that for emulator user server name and for device use server IP Address)

7. There are two main events during connection ObjXmppCon_OnAsyncConnectFinished and xMPPClient_OnStateChanged

First asyncConnectFinished should be executed , there I am setting a flag IsXmppSuccess

Soon after, followed by statechanged event there is a flag like below mentioned 

Enum XMPP State

8.  If XMPPState is ready then => server and credentials are correct.

     If XMPPState is AuthenticationFailed => Credentials are wrong.

     I am just navigating to other form Output.xaml if the XMPPState is Ready.

Step8

If there are any issues, I will try to solve them in above mentioned sample. Find the sample solution here

Contact me : nanda.kishore@ecanarys.com

Update

Please find related DLL here

 

Filed Under: 

Comments

Sarah Ballard's picture
By Sarah Ballard (Anonymous) on
I was just looking at your Using XMPP and Openfire Server in Windows Phone 8 | Canarys site and see that your site has the potential to become very popular. I just want to tell you, In case you didn't already know... There is a website service which already has more than 16 million users, and the majority of the users are interested in topics like yours. By getting your website on this network you have a chance to get your site more visitors than you can imagine. It is free to sign up and you can find out more about it here: http://thoschi.com/c - Now, let me ask you... Do you need your website to be successful to maintain your business? Do you need targeted visitors who are interested in the services and products you offer? Are looking for exposure, to increase sales, and to quickly develop awareness for your website? If your answer is YES, you can achieve these things only if you get your website on the service I am describing. This traffic service advertises you to thousands, while also giving you a chance to test the service before paying anything. All the popular blogs are using this network to boost their traffic and ad revenue! Why aren’t you? And what is better than traffic? It’s recurring traffic! That's how running a successful website works... Here's to your success! Read more here: http://greybeard95a.com/3fL

Add new comment