Team XSockets.NET

Configure The Connection

How to use multiple Controllers

To multiplex over several controllers on one connection you just pass in the controllers to use.

Below we connect to Controllers one and two

var conn = new XSocketClient("ws://localhost:4502", "http://localhost", "one","two");

Do note that you do not have to specify all controllers in the creation of the client. As soon as you start using a controller in the client API you will get an instance of it.

So if there is no controller three defined in the connection you can still do:

conn.Controller("three").Invoke("somemethod");

How to specify query string parameters

You can add querystrings to the NameValueCollection named QueryString on the IXSocketClient

var conn = new XSocketClient("ws://localhost:4502","http://xsockets.net", "chat");
conn.QueryString.Add("color","blue");
await conn.Open();

How to specify HTTP headers

var conn = new XSocketClient("ws://localhost:4502","http://xsockets.net", "chat");
conn.Headers.Add("headername", "headervalue");
await conn.Open();

How to specify client credentials

Connection header

var conn = new XSocketClient("ws://localhost:4502","http://xsockets.net", "chat");
conn.Headers.Add("myauthtoken", /* the token data */);
await conn.Open();

Then verify the token in a custom AuthenticationPipeline or in the OnOpen even of the specific controller

var authTicket = new FormsAuthenticationTicket(1, "Uffe",DateTime.Now,DateTime.Now.AddMinutes(15),false, "batman|hulk");            
string encTicket = FormsAuthentication.Encrypt(authTicket);
var authcookie = new Cookie(FormsAuthentication.FormsCookieName, encTicket);
conn.Cookies.Add(authcookie);

Certificate

var conn = new XSocketClient("ws://localhost:4502", "http://xsockets.net", "chat");
conn.AddClientCertificate(new X509Certificate2("mycert.pfx"));
await conn.Open();

results matching ""

    No results matching ""