0

I've been working on this for past 10 days. My task is this: to connect from Unity3D to SocketIO server that is using namespaces. The problem is that there isn't any usable SocketIO library for C# (without changing anything on server). So I'm forced to used regular WebSockets. I have found couple of libraries (currently using WebSocketSharp). I have managed to connect to regular SocketIO server but I need to find a way to connect to SocketIO that is using namespaces.

First I'm sending a http GET request to SocketIO server to get the handshake. Like this:

...new WebRequest("http://somewebsite.com:8080/socket.io/1/?t=" + time, "GET");

I got the "time" variable from function that is the same as JavaScript's getTime() function. After this I'm trying to connect to WebSocket like this:

...new WebSocket("ws://somewebsite.com:8080/socket.io/1/websocket/" + key[0]);

key[0] variable is just the response from the web request.

This all works when the arhitecture on SocketIO server side is regular, but how to implement all this with SocketIO server that is using namespaces?

I have inspected the Chrome's network traffic and only place where namespace is mentioned is under the Frames tab (on second request when the web socket is trying to connect).

Thank you.

EDIT: version of the SocketIO on server is 0.9.x

  • Take a look: http://stackoverflow.com/questions/6499861/communicating-with-a-socket-io-server-via-c-sharp – Leo Chapiro Jul 29 '14 at 13:02
  • Thank you for your response. As you can see that project hasn't been updated for last 2 years and it is still in beta. Reason for that is there is an Pomelo framework that can solve all of my problems and connect Unity with SocketIO. But I have no control over the server side. I'm programer on client side and my firm is requesting to do this with 0 changes on server side. – user3884087 Jul 29 '14 at 13:09

1 Answers1

0

I add namespace to c# SocketIOClient by manipulating url.

add namespace behind the url as below

http://somewebsite.com:8080/socket.io/1/[namespace]?t=

Ko Lynn
  • 134
  • 4
  • 8