XSockets / XSockets.Clients

Realtime clients for XSockets.NET 4.*
MIT License
11 stars 9 forks source link

ConnectionId / PersistentId on XSockets.Client is empty #7

Closed dannyyy closed 9 years ago

dannyyy commented 9 years ago

After establishing a connection to the server successfully the client hasn't a ConnectionId nor PersistentId set. Both properties returns Guid.Empty.

A sample project can be found here: http://www.heiniger.ch/cloud/XSocketsConnectionSample.zip

codeplanner commented 9 years ago

When you get the event "OnConnected" on client level this only means that you have a socket open and that the handshake is completed. You have not yet opened a controller. When you get "OnOpen" on a controller you will have both ConnectionId and PersistentId.

See this sample

var client = new XSocketClient("ws://localhost:4502", "http://localhost", new [] {"Test"});

client.OnConnected += (sender, args) =>
{
    //Socket is open and handshake is completed... but you will not have a ConnectionId or PersistentId.
    //You will have that once the controller is used... in this case when test is opened
    Console.WriteLine("PersistentId {0}", client.PersistentId);                
};

client.Controller("test").OnOpen += (sender, args) =>
{
    //Now you will have connectionId and PersistenId
    Console.WriteLine("PersistentId {0}", args.ClientInfo.PersistentId);
    Console.WriteLine("ConnectionId {0}", args.ClientInfo.ConnectionId);
};

client.Open();
dannyyy commented 9 years ago

Thank you very much! Issue can be closed.