coder71 Posted May 10, 2011 Share Posted May 10, 2011 Hello, Would you recommend WebSockets, SOAP, or some other transmission architecture for the following? I'm developing an online multiplayer (or single player vs the system) game, kind of like "Jeopardy!" in PHP. Users will log on, and if they choose to play against someone else in a different location, then the game will have to know who buzzed in first (clicked on a button on the screen) and instantly notify both players. The game will tell the first player that they buzzed in first, and the other player will instantly know that they they buzzed in after the first person and therefore can't answer. There could be X number of games simultaneously, but each game would have only 1-2 players. Questions would be stored in a MySQL db, as well as player credentials and score histories. Transmission from the server to the client and back would need to be encrypted. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/236016-websockets-or-soap-or-which-to-choose/ Share on other sites More sharing options...
requinix Posted May 10, 2011 Share Posted May 10, 2011 SOAP is awful heavy for (what I would expect to be) short messages. I'd go with raw sockets. Quote Link to comment https://forums.phpfreaks.com/topic/236016-websockets-or-soap-or-which-to-choose/#findComment-1213412 Share on other sites More sharing options...
coder71 Posted May 10, 2011 Author Share Posted May 10, 2011 By "raw sockets", do you mean WebSockets? If you mean "Sockets," does that work with just PHP? Quote Link to comment https://forums.phpfreaks.com/topic/236016-websockets-or-soap-or-which-to-choose/#findComment-1213464 Share on other sites More sharing options...
requinix Posted May 10, 2011 Share Posted May 10, 2011 Client-side? Yeah, WebSockets. Or Flash/Java until there's enough browser support for WebSockets (almost there!). For PHP you'd pair it with standard sockets - fsockopen and the like, as opposed to regular HTTP (ie, invoking PHP scripts like normal) and SOAP and other protocols which add a lot of overhead. Quote Link to comment https://forums.phpfreaks.com/topic/236016-websockets-or-soap-or-which-to-choose/#findComment-1213484 Share on other sites More sharing options...
coder71 Posted May 11, 2011 Author Share Posted May 11, 2011 Would anything else besides LAMP be needed on the server side? For example, would I need a console app on the server or anything like that? Thanks for all of your input! Quote Link to comment https://forums.phpfreaks.com/topic/236016-websockets-or-soap-or-which-to-choose/#findComment-1213513 Share on other sites More sharing options...
coder71 Posted May 11, 2011 Author Share Posted May 11, 2011 Also, I'd need the server to handle multiple requests from different games. I thought sockets were on only one port. If that's correct, then would I still be able to use this solution? Quote Link to comment https://forums.phpfreaks.com/topic/236016-websockets-or-soap-or-which-to-choose/#findComment-1213525 Share on other sites More sharing options...
requinix Posted May 11, 2011 Share Posted May 11, 2011 PHP is not the greatest at running for a long time. It works best for short-term usage. I think your Jeopardy game thing will be short enough to not be an issue: for now you can spawn a new PHP script for each game running, which terminates when the game is over. So no, for now you don't need more than a LAMP stack. You don't need to worry about switching ports - the OS will handle that work for you. You have whatever listen on a certain port, and when a connection is made, if accepted the connections will go elsewhere, thus freeing up the original port for more traffic. Quote Link to comment https://forums.phpfreaks.com/topic/236016-websockets-or-soap-or-which-to-choose/#findComment-1213545 Share on other sites More sharing options...
coder71 Posted May 11, 2011 Author Share Posted May 11, 2011 Excellent...thanks for the thorough answer! Quote Link to comment https://forums.phpfreaks.com/topic/236016-websockets-or-soap-or-which-to-choose/#findComment-1213563 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.