WebSocket service End With PHP, looked for a long time Baidu, all is not the main push

Source: Internet
Author: User
Tags php websocket

PHP websocket Issues

WebSocket service End with PHP, check for a long time Baidu, all is the client to send the message passive push, the server actively push how to do it, manual all in English.
To realize customer service and customer chat ideas how to do it (the client is H5, customer service is a PC, customer service answer how to call WebSocket server, and how to push to the corresponding customer service side), I hope the actual project experience of the predecessor informed.

Is it possible to initialize the user identity parameters directly while the client is connected?

function link(){    var url='ws://www.test.com:8000';    socket=new WebSocket(url);    socket.onopen=function(){        var json = JSON.stringify({'userid':'1001'});//怎么标注身份        socket.send(json);    }  socket.onmessage=function(msg){}  socket.onclose=function(){}}

I feel that this kind of thinking is wrong from the start, and today only began to contact such problems, but also hope that experienced predecessors informed.

Reply content:

PHP websocket Issues

WebSocket service End with PHP, check for a long time Baidu, all is the client to send the message passive push, the server actively push how to do it, manual all in English.
To realize customer service and customer chat ideas how to do it (the client is H5, customer service is a PC, customer service answer how to call WebSocket server, and how to push to the corresponding customer service side), I hope the actual project experience of the predecessor informed.

Is it possible to initialize the user identity parameters directly while the client is connected?

function link(){    var url='ws://www.test.com:8000';    socket=new WebSocket(url);    socket.onopen=function(){        var json = JSON.stringify({'userid':'1001'});//怎么标注身份        socket.send(json);    }  socket.onmessage=function(msg){}  socket.onclose=function(){}}

I feel that this kind of thinking is wrong from the start, and today only began to contact such problems, but also hope that experienced predecessors informed.

Http://www.workerman.net/workerman-chat
Can look at this, php written websocket chat room, customer service function can actually be used inside the single chat function. Someone uses it to implement a passer-by, including web pages and client software.
Development manual: Http://workerman.net/gatewaydoc/
demo:http://chat.workerman.net/

Phpwebim is the Swoole official WebSocket Web Instant Chat tool based on the PHP swoole extension and swoole framework development.
Phpwebim supports Websocket+comet two protocols that can be used for all kinds of browsers including IE.
Https://github.com/matyhtf/PHPWebIM
demo:http://webim.swoole.com/

Technical problems do not check what Baidu,?

I've used the WebSocket in Java. Probably the idea is that the client and server build WebSocket, and then the server side will this logo and this link to save the hashmap inside. When the message needs to be pushed through the identity (which the server provides to the client) to find the appropriate link, and then push the message past. These include some details of what the heartbeat detects. The general idea is this.

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.