2008-07-15

Develop an Enterprise class Instant Messenger client in .NET

So you want to develop an Instant Messenger like Yahoo, MSN, GTalk and want to have cool features like multi-user chat, emotions, rtf based chat messages, typing notifications, buddy status, custom status messages and bla bla bla but don't know how to proceed? Well XMPP is the answer. eXtensible Messaging and Presence Protocol (XMPP) formerly known as Jabber protocol, an open XML technology for presence and real-time communication developed by the Jabber open-source community in 1999. Today XMPP is much more than IM. Its a realtime system for presence, message and data exchange. GTalk is also based XMPP, so a client that supports Jabber/XMPP can connect to the Google Talk service. Google has extended the XMPP for voice signaling and peer-to-peer communication.

Before developing messenger client what you need is a Server where your messaging client will be connecting to. There are lots of good open source Communication Servers are available in the market. One of which is Openfire. Openfire (formerly Wildfire) is a real time collaboration (RTC) server dual-licensed under the Open Source GPL and commercially. It uses the only widely adopted open protocol for instant messaging, XMPP. Openfire is incredibly easy to setup and administer, but offers rock-solid security and performance. It can be downloaded from http://www.igniterealtime.org/projects/openfire/index.jsp. It can run on various operating systems like Windows, Linux, Unix but I will talking only about Windows. Openfire installer comes in two versions i.e. with JRE and without JRE. If you already have JRE on your machine/server then download the light weight installer without JRE otherwise go for the recommended installer that includes JRE.
To complete the installation of Openfire, you'll need to perform each of the following steps:

  • Database - if you choose to use an external database, you must prepare your database for Openfire.


  • Setup - Use the built-in web-based setup tool to setup and verify the server configuration.


  • Admin Console - use the web-based admin tool to manage the server.


There is a good Installation guide provided on the website. Openfire can store its data in an embedded database or you can choose to use an external database such as SQL Server, MySQL or Oracle. If you would like to use an external database, you must prepare it before proceeding with installation. View the database setup documentation for more information provided in the Installation guide.

A web-based, "wizard" driven setup and configuration tool is built into Openfire. Simply launch Openfire (platform-specific instructions below) and use a web browser to connect to the admin console. The default port for the web-based admin console is 9090. If you are on the same machine as Openfire, the following URL will usually work: http://127.0.0.1:9090/.

After completing the setup, you can use the web-based admin console to administer the server. The URL should be the same as you used to setup the server unless you changed the port during the setup.

Configure the Openfire to run it as a Windows Service so that it can also run even if the machine is in log-off mode.

Now, It's time to develop Messaging client. When I developed messaging client I used agsXMPP library. agsXMPP is a SDK for the eXtensible Messaging and Presence Protocol (XMPP) written in managed C#. The SDK is released as open source under a dual licence. It provides features like Presence, Roster (Contact list), Last Activity, Multi-User Chat, Vcard, Jabber Search, File Transfer, Chat State Notifications, etc. agsXMPP SDK comes with some samples written in C#, VB.NET which can be used as a guide to develop full fledged client.

So here you end up with a good solution for developing an Enterprise class Instant Messenger client in .NET. I used Openfire and agsXMPP for one of my previous company and it scaled well. My company wanted to block the messenger clients like Yahoo and MSN, so they asked me to develop a good Messaging client and I came up with this nice solution. Openfire scales very well, it easily handles few hundred connections on a Pentium 4 processor. It can also be confired to handle few thousand connections provided you have a dedicated server with good configuration.

5 comments:

Rick said...

I need to do exactly the same thing. How well did it work out? Would it scale to 10,000 users?

Deepak Sakpal said...

Rick,

In my case it worked out like a charm. It can scale to 10,000 users but for good results, you will need to have a dedicated server with good configuration. The best place to discuss about this is Ignite Realtime community forums.

.

Rishabh said...

ok I need your help now. I was able to setup Openfire using Openfire 3.4.1. Now the thing is that I am first trying to use Miniclient as an example. Can you help me connect it with Openfire server ?

Deepak Sakpal said...

Rishabh,

Make sure that open fire in running before you run Miniclient application. Miniclient application is very straight forward, you just need to enter the server ip or server name, user name and password.

jhony112 said...

Dz is kinda late.but I need your help.I need to know how to use agsxmpp in vb,net