简体   繁体   中英

client server constant communication PHP

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.

In todays world there are tons of options available for you. What you are looking for is a PUSH semantics rather than PULL ie 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

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. 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.

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. 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)

Hope it helps you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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