views:

62

answers:

1

Hi, let me introduce my story first. To develop a multiplayer network game in facebook, flash used to be a king but it consumes a lot of resources for client and I feel like it isn't worth for a card game. So I come with an idea that front-end will use Javascript (of course with jQuery) and backend with PHP. But for real-time communication, it isn't possible just with PHP and Javascript. It doesn't make sense to record every movement of players in MySQL and display back to another browsers. So I come with an idea with XMPP Services. XMPP services can even communicate browser to browser and display contents with Strophe and Javascript even without with PHP.

Finally, I've got every tools I need but I have few questions that I can't answer myself.

1) How XMPP server work between PHP and Javascript? I need to get/post user records from MySQL and calculate movements then forward results to intended user. There will be an Authentication system too so that's gonna be taken care by PHP as I'm not wrong.

2) This question is the title of this post.. Is it possible to run XMPP based PHP and Javascript Multiplayer Network Game in FaceBook?

Thanks in advance for all of your time and advices!

+1  A: 

The connection would work using PHP sockets, and you could easily use Ajax to send data to PHP to send on to the XMPP server. There are also a number of libraries for communicating with XMPP servers using PHP. As for Facebook, it shouldn't have any effect on your script - if I remember correctly Facebook runs your app in its own sandbox so you shouldn't have to do anything special to get around the Facebook API.

Jarrod
Thanks for yr answer! Just one more question :)... you wrote Ajax to PHP to XMPP, right! Is that mean a movement data from a browser is sent with Ajax to PHP and then forwarded to XMPP server and then pass to another browser's XMPP client through PHP?
Devyn
I assume so - I'm not entirely sure on if you could perform socket communication with only Javascript. Think of PHP in this case as the vehicle between your XMPP server and the client. Use a timer in Javascript to fire an Ajax request for PHP to ping the server for new moves.
Jarrod