简体   繁体   English

是否可以在FaceBook中运行基于XMPP的PHP和Javascript多人网络游戏?

[英]Is it possible to run XMPP based PHP and Javascript Multiplayer Network Game in FaceBook?

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. 为了在Facebook中开发多人网络游戏,Flash曾经是国王,但它为客户端消耗了大量资源,我觉得这不值得玩纸牌游戏。 So I come with an idea that front-end will use Javascript (of course with jQuery) and backend with PHP. 因此,我想到一个想法,即前端将使用Javascript(当然使用jQuery),后端将使用PHP。 But for real-time communication, it isn't possible just with PHP and Javascript. 但是对于实时通信,仅靠PHP和Javascript是不可能的。 It doesn't make sense to record every movement of players in MySQL and display back to another browsers. 在MySQL中记录玩家的所有动作并显示回另一个浏览器是没有意义的。 So I come with an idea with XMPP Services. 所以我想到了XMPP Services。 XMPP services can even communicate browser to browser and display contents with Strophe and Javascript even without with PHP. XMPP服务甚至可以在没有PHP的情况下使用Strophe和Javascript在浏览器之间通信并显示内容。

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? 1)XMPP服务器如何在PHP和Javascript之间工作? I need to get/post user records from MySQL and calculate movements then forward results to intended user. 我需要从MySQL获取/发布用户记录并计算移动量,然后将结果转发给目标用户。 There will be an Authentication system too so that's gonna be taken care by PHP as I'm not wrong. 还将有一个身份验证系统,因此PHP会注意这一点,因为我没错。

2) This question is the title of this post.. Is it possible to run XMPP based PHP and Javascript Multiplayer Network Game in FaceBook? 2)这个问题是这篇文章的标题。是否可以在FaceBook中运行基于XMPP的PHP和Javascript Multiplayer Network Game?

Thanks in advance for all of your time and advices! 预先感谢您的所有时间和建议!

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. 该连接将使用PHP套接字进行工作,并且您可以轻松地使用Ajax将数据发送到PHP以发送到XMPP服务器。 There are also a number of libraries for communicating with XMPP servers using PHP. 还有许多用于使用PHP与XMPP服务器通信的库 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. 至于Facebook,它对您的脚本不会有任何影响-如果我没记错的话,Facebook在自己的沙箱中运行您的应用程序,因此您无需做任何特别的事情来避开Facebook API。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM