Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Register New Account using Matrix XMPP Library

0.00/5 (No votes)
3 Sep 2011 1  
Register New Account using Matrix XMPP Library

Introduction

In this article, I'm going to explain how to create a new account on XMPP server using MatriX library.

What is MatriX

MatriX is a library for the eXtensible Messaging and Presence Protocol (XMPP) for the Microsoft .NET platform. MatriX can be used to build high quality and high performance XMPP Software products.

To get started with the Matrix XMPP library, you can download the SDK here.

What is XMPP

XMPP is a shortcut of Extensible Messaging and Presence Protocol, which is an open standard communication protocol for message-oriented middleware based XML. The XMPP is an open XML technology for real-time communication, which powers a wide range of applications including instant messaging, presence, media negotiation, whiteboarding, collaboration, lightweight middleware, content syndication, and generalized XML routing.

Register New Account

Here you need to set the username, password and domain name of the XMPP server.

If you are going to create a new account, you need to enable the RegisterNewAccount as xmppClient.RegisterNewAccount = true.

XmppClient regXmppClient = new XmppClient();

    regXmppClient.OnRegister += new EventHandler<matrix.eventargs />(xmppCon_OnRegister);
    regXmppClient.OnRegisterInformation += 
			new EventHandler<matrix.xmpp.register.registereventargs />(xmppCon_OnRegisterInformation);
    regXmppClient.OnRegisterError += new EventHandler<matrix.xmpp.client.iqeventargs />(xmppCon_OnRegisterError);

    regXmppClient.SetUsername(username);
    regXmppClient.SetXmppDomain("Your domain");
    regXmppClient.Password = password;
    regXmppClient.RegisterNewAccount = true;

    regXmppClient.Open();

Handlers

private void xmppCon_OnRegisterInformation(object sender, RegisterEventArgs e)
{
    e.Register.Username = regXmppClient.Username;
    e.Register.Password = regXmppClient.Password;
}

private void xmppCon_OnRegister(object sender, Matrix.EventArgs e)
{
    //Registration success
}

private void xmppCon_OnRegisterError(object sender, IqEventArgs e)
{
    //Error
}

What is BOSH

BOSH is standard for Bidirectional-streams Over Synchronous HTTP and it can be used to transport XMPP stanzas. The result is an HTTP binding (BOSH) for XMPP communications that is useful in situations where a device or client is unable to maintain a long-lived TCP connection to an XMPP server.

How to Use BOSH

If you are going to use BOSH instead of socket, you need to set the transport type as BOSH.

regXmppClient.Transport = Matrix.Net.Transport.BOSH;
regXmppClient.Uri = new System.Uri("http://localhost:5280/http-bind");

Get the Latest Binary

Get the latest version of MatriX library from here.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here