Click here to Skip to main content
Click here to Skip to main content

Register New Account using Matrix XMPP Library

, 3 Sep 2011
Rate this:
Please Sign up or sign in to vote.
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, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

K.Kirivarnan
Software Developer
Sri Lanka Sri Lanka
No Biography provided
Follow on   Twitter

Comments and Discussions

 
Questionxmpp server PinmemberRavenet12-Dec-13 14:21 
QuestionLicensing for Matrix Libraries. Pinmembercalvfre5-Sep-11 17:33 
AnswerRe: Licensing for Matrix Libraries. [modified] PinmemberK.Kirivarnan6-Sep-11 0:28 

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

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

| Advertise | Privacy | Mobile
Web04 | 2.8.140709.1 | Last Updated 3 Sep 2011
Article Copyright 2011 by K.Kirivarnan
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid