I was wondering if it's possible to use XSocket as a client and Socket.IO as the server side.
I was pretty sure that it wouldn't work but then I read this post, which is effectively the opposite of what I'd like to do. and that seems to work. The major difference I guess is that I'm not writing the server, I'm just trying to use one that already exists.
Here's what I have so far:
public static void Main (string[] args)
{
try{
const string ClientID = "--MyClientID--";
const string AccessToken = "--MyAccessToken--";
XSocketClient client = new XSocketClient ("https://streamtip.com", "https://streamtip.com", "StreamTipIO");
client.QueryString.Add("client_id", Uri.EscapeDataString(ClientID));
client.QueryString.Add("access_token",Uri.EscapeDataString(AccessToken));
client.OnError +=
(object sender, XSockets.Client40.Common.Event.Arguments.OnErrorArgs e) => Console.WriteLine (e);
client.OnConnected +=
(object sender, EventArgs e) => Console.WriteLine ("Connected");
client.OnDisconnected +=
(object sender, EventArgs e) => Console.WriteLine ("Disconnected");
client.OnPing +=
(object sender, XSockets.Client40.Model.Message e) => Console.WriteLine (e);
client.OnPong +=
(object sender, XSockets.Client40.Model.Message e) => Console.WriteLine (e);
//client.Controller("test").On("authenticated", () => Console.WriteLine("test"));
client.Controller("StreamTipIO").On<string>("authenticated", Console.WriteLine);
client.Open();
}
catch(Exception e)
{
Console.WriteLine (e);
}
Console.ReadLine ();
}
The weird bit is It seems to connect, but I'm not getting any data.... I assume this is something to do with Controllers and the fact I just made on up, as I'm not sure what you'd name the controller when trying to use a Socket.IO backend...
--Output
Disconnected
Connected
Oddly enough disconnected fires first.... not sure what that's about
On a side note:
I'd like to beable to connect to Socket.IO servers in C# but it seems really arbitrary.. I've already tried a few C# Socket.Io ports, SocketIoClientDotNet actually works perfectly, until you try to run it in Mono then it has this error