简体   繁体   中英

php mysql background process

i have developing a website that user can chat with other user if they are online . if one user send a message will notify that receiver on their screen , these checking process are happen in background process , i have an option of using

setinterval method and javascript self execution method

but i am looking much faster background process methods which will check every seconds if message or notification arrived .

could any one give suggestion for this.

You can use HTML5 websockets.

WebSockets is an advanced technology that makes it possible to open an interactive communication session between the user's browser and a server. With this API(JS functions), you can send messages to a server and receive event-driven responses without having to poll the server for a reply.

below is good link to start

http://www.sanwebe.com/2013/05/chat-using-websocket-php-socket

I think the best match for your needs will be http://elephant.io

Elephant.io provides a socket.io client fully written in PHP that should be usable everywhere in your project.

Take a look at the Thruway Project . It's a PHP websocket implementation using the WAMP protocol, which gives you Publish and Subscribe abilities (you can use that for your chat application) as well as RPC.

A good place to start would to take a look at this chat demo ( source code ) and then use Thruway as the WAMP router.

I'm one of the developers of the thruway project, so if you run into any issues or have any questions, feel free to ask.

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