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).
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
- 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
- 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
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).
3. Refer those library phone.socketserver.dll and phone.xmpp.dll
4. Login panel UI is shown below
5.In MainPage.xaml.cs create some properties as shown below.
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
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.
If there are any issues, I will try to solve them in above mentioned sample. Find the sample solution here
Contact me : email@example.com
Please find related DLL here