vapor-community / sockets

🔌 Non-blocking TCP socket layer, with event-driven server and client.
MIT License
575 stars 54 forks source link

WebSocket and Socks #81

Closed PhilipHayes closed 8 years ago

PhilipHayes commented 8 years ago

So I've started up a TCP server with socks and a TCP Client with straight Javascript.

I get the initial request from my javascript client to my Socks server, but however I have no idea what to send back to the javascript client to allow it to upgrade and begin sending and receiving data. I've had this issue with various WebSocket clients of not being able to complete the connection...

In Socks what should I do? my server is basically the sample code you've provided, and the client is the sample code provided here: http://www.tutorialspoint.com/html5/html5_websocket.htm

ironically, I do get the disconnect message when I turn off my server.

I also tried using the Socks TCPSocket Client and I get roughly the same issue, I can send the first message, and then nothing works after that.

tanner0101 commented 8 years ago

Any reason you don't want to use our WebSockets module from https://github.com/vapor/engine?

PhilipHayes commented 8 years ago

Oh I'll have to look into this, I was following the documentation and ended up with Socks instead.

PhilipHayes commented 8 years ago

Okay so I replaced my server with the engine one, and my javascript client now lists itself as connected. but it seems that any communication that happens for 'onopen' doesn't happen.

This is definitely closer, Its the sample code from engine and the sample code from the html5 web socket.

I'm using an html client because I'm working with Rot.js as a front-end for my server. (I want to be able to replace the front-end with things like Unity or Simple DirectMedia Layer for games.)

tanner0101 commented 8 years ago

This slackbot written in Vapor uses websockets: https://github.com/vapor/penny

That might help you more. Websockets should be perfect for a real-time game.

PhilipHayes commented 8 years ago

Excellent, I think i've got it all running now! I'm going to get to building my app. Thank you for your guidance!