Click here to Skip to main content
15,882,017 members
Articles / Programming Languages / C#

Register New Account using Matrix XMPP Library

Rate me:
Please Sign up or sign in to vote.
0.00/5 (No votes)
3 Sep 2011CPOL1 min read 20.2K   8   4
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.

C#
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

C#
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.

C#
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, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
Singapore Singapore
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
QuestionRegister New Account using Matrix XMPP Library Pin
Member 1313243114-Dec-17 2:06
Member 1313243114-Dec-17 2:06 
Questionxmpp server Pin
Ravenet12-Dec-13 14:21
Ravenet12-Dec-13 14:21 
QuestionLicensing for Matrix Libraries. Pin
calvfre5-Sep-11 17:33
calvfre5-Sep-11 17:33 
AnswerRe: Licensing for Matrix Libraries. [modified] Pin
K.Kirivarnan6-Sep-11 0:28
K.Kirivarnan6-Sep-11 0:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.