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
xmppClient.RegisterNewAccount = true.
XmppClient regXmppClient = new XmppClient();
regXmppClient.OnRegister += new EventHandler<matrix.eventargs />(xmppCon_OnRegister);
new EventHandler<matrix.xmpp.register.registereventargs />(xmppCon_OnRegisterInformation);
regXmppClient.OnRegisterError += new EventHandler<matrix.xmpp.client.iqeventargs />(xmppCon_OnRegisterError);
regXmppClient.Password = password;
regXmppClient.RegisterNewAccount = true;
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)
private void xmppCon_OnRegisterError(object sender, IqEventArgs e)
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.