Why prebind and attach?
When your web application is already logged in and needs to establish a XMPP connection you have a seamless and secure solution with prebind and attach. You don’t have to ask the user to provide the credentials again, and you don’t have to render the credentials insecure in your HTML output.
Prebind with MatriX
This code shows how to prebind a session with MatriX. On success MatriX raises the OnPrebind event and provides the Jid, Rid and Sid in the PrebindEventArgs. The Rid is the last one used by MatriX and must be incremented before getting passed to Strophe.
You can render this params in a new page and attach the session with Strophe.
var xmppClient = new XmppClient { Username = "testuser", XmppDomain = "ag-software.de", Password = "secret", Transport = Matrix.Net.Transport.BOSH, Uri = new System.Uri("http://ag-software.de/http-bind/") }; // subscribe to the prebind event xmppClient.OnPrebind += client_OnPrebind; void client_OnPrebind(object sender, PrebindEventArgs e) { prebindArgs = e; are.Set(); } // start prebinding with MatriX now xmppClient.Prebind();
You can download a complete ASP .NET example project here:
Bosh Prebind Example
Leave a Reply