客户端服务器常量通信PHP [英] client server constant communication PHP

查看:167
本文介绍了客户端服务器常量通信PHP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想制作一个简单的游戏(应用程序),网页浏览器游戏多人游戏,需要与服务器不断连接。

现在,即时通讯使用ajax和普通的php wamp服务器,但我认为这是错误的方式,因为我需要每秒向服务器发送请求(更新)...这似乎是错误的..

i知道一些比比皆是的项目,但我需要一些东西用于Windows(现在)

我还有其他选择吗? web-socket有点棘手,很多老浏览器都不支持,所以它不好......请帮忙,谢谢。

i want to make a simple game(application), web browser game multiplayer game, that require constant connection with the server.
right now, im using ajax and normal php wamp server, but i think it is the wrong way to go because i need to send request to the server every second(for update)from each user... it seems just wrong..
i know something abound ape-project, but i need something for windows(for now)
what other option i have? web-socket is a bit tricky and not supported by a lot of old browser, so it is not good... please help, and thanks ahead.

推荐答案

在当今世界,有很多选择可供选择。您正在寻找的是PUSH语义而不是PULL即您不希望从客户端(定期)POLL服务器获取新更新,但您希望服务器在客户端可用时将数据推送到客户端。

In todays world there are tons of options available for you. What you are looking for is a PUSH semantics rather than PULL i.e. You don't want to POLL servers from client (periodically) for new updates, but you want server to PUSH data to client as and when it is available.

您应该查看发布者 - 订阅者工作流,每个用户可以有一个频道,其他用户可以在其中发布更新。然后,每个用户都会订阅它的频道以实时检索任何更新

You should look at Publisher-Subscriber workflows, where you can have one channel per user where other users can publish there updates. Each user will then subscribe to it's channel to retrieve any updates in real-time

市场上有很多现成的pubsub解决方案。我想到的一些是:

There are a lot of readymade pubsub solutions available in the market. A few that comes to my mind are:


  1. Redis PubSub

  2. XMPP PubSub

  3. 如果你真的不关心PubSub本身及它的部署/工作/技术,请去第三方服务提供商,如 SuperFeedr PusherApp PubNub 和其他人。我认为市场上至少有10个此类服务提供商。

  1. Redis PubSub
  2. XMPP PubSub
  3. If you don't really care about PubSub yourself and it's deployment/working/tech, go for 3rd party service providers like SuperFeedr, PusherApp, PubNub and others. I think there are atleast 10 such service provider out in the market.

您还需要一个将pubsub频道连接到客户端的传输在浏览器上(websocket或在旧浏览器上为您模拟websocket的东西)。我想到的一些选择是:

You will also need a transport that connects your pubsub channels to clients on the browser (websocket or something that emulates websocket for you on old browsers). A few options that comes to my mind are:


  1. 使用 BOSH连接管理器(长轮询)

  2. Socket.IO

  3. Sock.JS

  4. STOMP (面向流式文本的消息传递协议)

  5. 如果你想使用免费和开源软件(FOSS),还有至少10个可用的现成选项

  1. Use a BOSH connection manager (long-polling)
  2. Socket.IO
  3. Sock.JS
  4. STOMP (Streaming Text Oriented Messaging Protocol)
  5. Again there are atleast 10 such available ready made options if you want to use Free and Open Source Softwares (FOSS)

希望它帮助你。

这篇关于客户端服务器常量通信PHP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆