Jump to content

  • Log In with Google      Sign In   
  • Create Account


Socket.io / PHP / MySQL


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
4 replies to this topic

#1 Ruccopia   Members   -  Reputation: 100

Like
0Likes
Like

Posted 25 October 2011 - 12:25 AM

Hi all.. I am new here and have been looking around the forum for a few days now, lots of interesting and helpful resources.... a great community!

I am part of a team whos been running a MMORPG for a number of years... it quite basic because it hasnt been touched in about 4 years... so for example there's no AJAX.

We are now working on overhauling the game and are looking at using reverse AJAX for push requests to the client browser. I have used normal pull AJAX before using the Sarissa framework, which I found easy to use and reliable.

Being a mass multiplayer game we need to be able to cater for large numbers of active players. I dont particularly want to poll the server(s) for updates but want to use boradcasts from the server when the clients need updating. For example when a clients stats change, or someone chats to them etc...

I have been investigating the use of Socket.IO so we can use WebSockets. I am new to socket programming so having some difficulties and am in need of some help - and am willing to pay.

What I basically want is a working example/prototype of the use of Socket.IO. We use a LAMP configuration and basically need the "server" to pull data from our MySQL database then broadcast it back to one client, or many clients. I also want the clients to be able to send messages to the server and then have that server process that data, connect to the DB (store data), then broadcast messages back to the client.

Can someone help me with this? Like I said willing to pay.

Look forward to working with someone!

Sponsor:

#2 hplus0603   Moderators   -  Reputation: 4904

Like
0Likes
Like

Posted 25 October 2011 - 06:33 PM

What I basically want is a working example/prototype of the use of Socket.IO. We use a LAMP configuration and basically need the "server" to pull data from our MySQL database then broadcast it back to one client, or many clients. I also want the clients to be able to send messages to the server and then have that server process that data, connect to the DB (store data), then broadcast messages back to the client.


I found some socket.io examples:
http://www.lmgtfy.com/?q=socket.io+examples

However, I think that your architecture is fundamentally wrong for what you want to do. If you want to push updates with low latency, taking the data out of MySQL just isn't the way to do it. It would be better to use something like a node.js or webmachine server with persistent connections from clients. You can, for example, request a HTML document that is chunked transfer encoding, and where you push a new <script></script> block each time there's some new event. Or you can use double-buffered AJAX requests for JSON data. These methods are going to be a lot simpler and more compatible than using WebSockets.

If all players can fit on a single node.js or webmachine server (which is likely for most indie games), then your system can be as easy as a persistent process that serves HTTP requests and returns messages that are pushed in by other users.
enum Bool { True, False, FileNotFound };

#3 Ruccopia   Members   -  Reputation: 100

Like
0Likes
Like

Posted 26 October 2011 - 04:03 AM

Appreciate the reply!

My understanding was that socket,io does use node.js (I thought I read it somewhere)... maybe Im wrong.

Our data is in MySQL so if not MySQL then how? Player statistics and other data is in there we need to return back to the client. So basically when player data is updated I want the server push to the client the new stats. As well as other things... chat etc...

I'm happy to use node.js, just want an example that I can use that relates to what I'm doing. Im here to get advice and happy to try something you think will be better for the application. The first step we have is deciding which way to go then get someone to build a prototype of it working. From there I can do the rest.

#4 hplus0603   Moderators   -  Reputation: 4904

Like
0Likes
Like

Posted 26 October 2011 - 12:06 PM

Our data is in MySQL so if not MySQL then how? Player statistics and other data is in there we need to return back to the client. So basically when player data is updated I want the server push to the client the new stats. As well as other things... chat etc...


As I said, the real-time data needs to live in RAM. Databases are for things that must live for a long time. That does not include chat :-) The main problem here is making sure that everyone who needs to know the same data is connected to the same RAM, if you use more than one server machine. If you can stick to a single server, this becomes easy!
For player data, you can have whomever updates the player data both checkpoint it into the database, and push a notification to anyone who's interested.
Redis publish/subscribe may also be a useful mechanism for those kinds of updates. as would perhaps some of the dedicated message queues like RabbitMQ, ZeroMQ, etc.
enum Bool { True, False, FileNotFound };

#5 Peter Moskovits   Members   -  Reputation: 100

Like
0Likes
Like

Posted 27 October 2011 - 01:32 PM

One more thing to consider is what level of investment you can/want to make into your custom messaging in the browser. One option is using the low-level WebSocket messages, but when it goes beyond the very basic samples, you will more often than not find yourself reinventing the wheel by developing some sort of a custom protocol.
What I see developers finding useful is having the messaging protocols extended all the way to the browser, allowing them to code against AMQP or JMS. While you're developing against AMQP/JMS, the messages are sent over WebSocket all the way to your AMQP/JMS back-end server.

Also, if interested, here are some pretty cool hosted demos you may find useful: interactive games remote controlled by a tilt-enabled mobile devices, as well as lower level core JMS demos.

Hope this helps,
Peter




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS