Closed dannyyy closed 9 years ago
This is due to the fact that the controller never will have a connectionId unless it is specified in the call to the XSocketClient ctor. The change to be able to do what you want is easy though.. Just have to change the condition in the Invoke method on the client... Instead of checking the ConnectionId we have to check the IsHandshakeDone flag...
From:
public virtual void Invoke(IMessage payload)
{
if (!this.XSocketClient.IsConnected)
throw new Exception("You cant send messages when not connected to the server");
payload.Controller = this.ClientInfo.Controller;
var frame = GetDataFrame(payload).ToBytes();
//If controller not yet open... Queue message
if (this.ClientInfo.ConnectionId == Guid.Empty)
{
this.queuedFrames.AddRange(frame);
return;
}
this.XSocketClient.Socket.Send(frame, () => { }, err => FireClosed());
}
To:
public virtual void Invoke(IMessage payload)
{
if (!this.XSocketClient.IsConnected)
throw new Exception("You cant send messages when not connected to the server");
payload.Controller = this.ClientInfo.Controller;
var frame = GetDataFrame(payload).ToBytes();
//If controller not yet open... Queue message
if (!this.XSocketClient.IsHandshakeDone)
{
this.queuedFrames.AddRange(frame);
return;
}
this.XSocketClient.Socket.Send(frame, () => { }, err => FireClosed());
}
I will push the changes to the repo now so that you can build it if you want to, but the release to nuget will not be done today.
Included in 4.2.0 that will be released 2015-03-30
Trying to connect to a XSockets server without using the third parameter
params string[] controllers
will establish successful a connection but controller invocation has no effect.Doesn't work:
var client = new XSocketClient("ws://localhost:4502", "http://localhost");
Work:
var client = new XSocketClient("ws://localhost:4502", "http://localhost", new[] {"Test});
Sample project can be found here: http://www.heiniger.ch/cloud/XSocketsControllerSample.zip