steveo16 Posted May 24, 2016 Share Posted May 24, 2016 Hey there. I was just curious how many people were using long polling or WebSockets for their online games. I'm working on a turn-based game that feels a bit like a board game in the browser, and for the early prototype I've opted to use long polling because it was easier to setup. At some point I'd like to make the switch to WebSockets, but if enough people seem to be having success with long polling then I'll probably de-prioritize the effort. Currently my game uses a 7 second refresh interval so there's a _bit_ of lag, but most of the time it isn't too noticeable. I was hoping to hear other people's thoughts on the matter. Thanks! Quote Link to comment Share on other sites More sharing options...
mattstyles Posted May 25, 2016 Share Posted May 25, 2016 Get yourself on the sockets bandwagon, support is now superb and there are a few wrapper libraries you can use to smooth out any edges. Once you've learnt it (it literally takes 2 minutes, its just an event emitter) its far easier to set up than long polling and most libraries will fall back to long polling if they can't establish a socket connection. There are plenty of guys and gals working on real-time connected games here, this is one. Quote Link to comment Share on other sites More sharing options...
steveo16 Posted May 25, 2016 Author Share Posted May 25, 2016 Darn, I was really hoping to move an item to the backlog but it sounds like WebSockets should be a priority. I have some old socket code from a chat app I can dust off. I'm kind of kicking myself for not using that code in the first place. Thanks for your feedback! Quote Link to comment Share on other sites More sharing options...
kevdude Posted June 11, 2016 Share Posted June 11, 2016 I agree with @mattstyles. I'm not sure what your server setup is but using nodejs and the ws library takes time to setup at first, but becomes very intuitive and fast. There is also plenty of documentation on how to implement it. Here's an example of one of my projects that uses WebSockets. Here's is another one as well. Quote Link to comment Share on other sites More sharing options...
steveo16 Posted June 13, 2016 Author Share Posted June 13, 2016 I guess this would give me a good opportunity to learn NodeJS. My old socket server code is written in PHP and is probably pretty dated by now. Do you happen to have any experience with wss, or secure WebSockets? What's the best way to make sure the WebSocket connection is encrypted and secure? Quote Link to comment Share on other sites More sharing options...
smartyMARTY Posted June 13, 2016 Share Posted June 13, 2016 I am using WebSockets for my game and only use traditional HTTP Requests in response to an action when needed - like loading player info. I have always hated long polling so when I could, the first thing I did was use websockets, I didn't regret it. There are also a lot of libraries out there too. They even fallback to long polling if needed (at least some of the ones I have looked at). Quote Link to comment Share on other sites More sharing options...
mattstyles Posted June 14, 2016 Share Posted June 14, 2016 13 hours ago, steveo16 said: I guess this would give me a good opportunity to learn NodeJS. My old socket server code is written in PHP and is probably pretty dated by now. Do you happen to have any experience with wss, or secure WebSockets? What's the best way to make sure the WebSocket connection is encrypted and secure? I've never encrypted websockets, although they're just http so the same principles apply using tls/ssl. Encryption is almost always a good option but a lot of the time your ws connections aren't carrying much information, or should not be, so there is a counter argument that man-in-the-middle attacks are fairly useless for anything other than disrupting your game as no sensitive info is ever in the pipe. Having said that it should be dead easy to set up now and cheap too. Maybe look at Let's Encrypt for your certs. Quote Link to comment Share on other sites More sharing options...
steveo16 Posted June 14, 2016 Author Share Posted June 14, 2016 I setup some basic socket server encryption in the past using stunnel. It seemed kind of hacky so I was wondering if there's a better way to go about it. I'm a big fan of encrypting all the things, so if I do end up switching from long polling to websockets I'll definitely want some kind of encryption in place. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.