Using XMPP and Openfire server in ASP.NET C# - Part -1

Extensible Messaging and Presence Protocol (XMPP)

The Extensible Messaging and Presence Protocol (XMPP) is a protocol for streaming XML elements in order to exchange messages and presence information.
The XMPP Core uses main features like
  • XML Streams
  • TLS
  • SASL
  • IM
The basic functionality expected of XMPP is instant messaging (IM) and for user presence in application.

Important requirement are

  •  Exchange messages with other users
  •  Exchange presence information with other users
  •  Manage subscriptions to and from other users
  •  Manage items in a contact list (in XMPP this is called a "roster")
  •  Block communications to or from specific other users
There are many providers who had built in libraries as mentioned in XMPP Standard foundation check linkhttp://xmpp.org/xmpp-software/libraries/ .
The example below described is based on the agsXMPP SDK developed in, managed C# dedicated to .NET and Mono technologies. Since, it is dual licensed (GPL) free DLL developed by ag-software.net and they also provide support for issues.
Before moving onto example there is important requirement to implement chat i.e., Chat server installation. I am using Openfire server to fulfill the requirement. For installation follow the link http://www.igniterealtime.org/projects/openfire/documentation.jsp

Important particulars for this implementation is

  •  JID – Jabber Id, a unique id in the openfire server for each user.
  • Roster- User’s contact is roster.

How to login to the server?

        Add the following code after successful login from your application.
        AgsXMPP.XmppClientConnection objXmpp = new agsXMPP.XmppClientConnection();
        Jid jid = new Jid ("xyz@server name"); //ex: xyz@abc.com – abc is the server 
       objXmpp.Server = jid.Server;
       objXmpp.Username = jid.User;
       objXmpp.Password = ******; //your password of account.
       objXmpp.AutoResolveConnectServer = true;
      objXmpp.OnLogin += loggedIn; // loggedIn is handler for successful login to server.
      objXmpp.OnAuthError += loginFailed;
      objXmpp.Open ();
     Catch (exception ex)

The loggedin handler is shown below

     Private void loggedIn (object o)
      //Logged in and Active

The login failed handler is shown below

      Private void loginFailed (object o, agsXMPP.Xml.Dom.Element el)
       //Invalid credentials
 When the loggedin handler executes it assures you that user credentials are valid and logged in.
  Part 1 we discussed only on the Login part using AgsXmpp .
  In next part i.e., Part 2 we shall discuss upon Recieving roster list of the user using AgsXmpp.



What are Frames? How to handle frames in Selenium WebDriver with C#?

IFrame (FullForm: Inline Frame) is an HTML document that is included in another HTML document and is...

Read More >

What is Synchronization? Handling Synchronization in Selenium WebDriver using C#:

Synchronization meaning: when two or more components involved to perform any action, we expect these...

Read More >

Sending Test reports by Email using Office 365, Gmail

Wouldn’t it be great if Test Report are sent automatically across team as soon the Test Execut...

Read More >

Token Based Authentication for Web API's

Securing ASP.NET Web API using Custom Token Based AuthenticationProviding a security to the Web API&...

Read More >

Extent Reports in Selenium CSharp (C#)

Reports play a fundamental role when it comes to TESTING. Tester can now  know the real-time r...

Read More >

How to Set Up Selenium WebDriver in Visual Studio Enterprise 2015?

Pre-requisite : Visual Studio Enterprise 2015 application should be installed into the system.Create...

Read More >

Custom Control in WPF

File Upload Custom Control in WPFThis article is about Custom control in WPF, Custom controls are al...

Read More >

ASP.NET: Audit Trail Implementation using Entity Framework

When you are working with certain projects which involves the Customer records, you might need to tr...

Read More >

Create Restful service using Web API

What is Asp.Net Web API?Asp.Net Web API is a framework for building HTTP services that can be consum...

Read More >

Dependency Injection on SignalR


Read More >


Post a Comment

  • Recent
  • Popular
  • Tag
Monthly Archive

Contact Us
  • *
  • *