Real-time communication with PHP and Websocket--GoEasy

When it comes to websocket, you must be familiar with it. WebSocket is a new protocol of HTML5. It implements full-duplex communication between the browser and the server. The initial handshake needs to be completed with the help of an HTTP request. After the browser and the server handshake successfully, a fast channel is formed between the browser and the server. Data can be transferred directly between the two. With websocket, you can abandon the previous way of using polling to achieve real-time communication.
With websocket, there are not a few related products that came into being, and the choice has become the biggest problem. Here you may say "why use someone else's, I can use the original one myself". I want to say that you are really NB, and I would also like to know how you solved the following problems:
1. Do you plan to spend 1 month, 2 months or 1 year to implement a websocket communication? If you say that you plan to spend a month, it means two points, your technology is going to heaven (you can make such a tricky thing so quickly and there is no performance problem, except for my existing knee, please put my knee in the next life Take it away too), your company's local tyrant (your company's hot pursuit of technology has reached the peak of the industry, it seems that your project is not very tight, the budget is quite large, tell me the name of your company, I will also study technology , hahaha)
2. Websocket only supports ie10+, chrome, firefox, safari, opera. Not to mention, there are still many user groups of IE9 and lower versions. How do you feel about the real-time communication of these lower version browsers?
The above two problems are nothing more than two aspects: development cost and browser compatibility. From the perspective of managers, they all hope to reduce development costs as much as possible, so choosing a third-party push service is a rational choice for many companies. When choosing
a product, you need to pay attention to the following points:
1. Is the code structure clear and easy to understand
?


Well, here comes the point, I don't judge the pros and cons of other products, I only give a one-sided evaluation of the product I finally chose - GoEasy Push . GoEasy push meets all the metrics I listed above.
1. Is the code structure clear and easy to understand
? GoEasy's code is divided into two parts:
subscription and push: when subscribing, only three lines of code are required:
a. Introduce goeasy.js (the file is very small)

<script type="text/javascript" src="http://cdn.goeasy.io/goeasy.js"></script>


b. Create a goeasy instance

var goEasy = new GoEasy({appkey: 'appkey'});


c. Subscribe to the channel.

goEasy. subscribe({
                 channel: 'channel1',
                 onMessage: function(message){
                              alert('Meessage received:'+message.content);//Received the push message
                           }
                    });


When pushing, use the restful api provided by goeasy. The api only needs three parameters:
URL: http://goeasy.io/goeasy/publish
Method: Post
Parameters: appkey, channel, content
2. What is the message arrival rate? In this way, whether the data arrives depends
on the fact that the concurrent users of our project are currently at a maximum of 300, and 30 messages are pushed every day. The arrival of each message can be viewed on the goeasy background page. As for the arrival rate, our project's requirement for the arrival rate is 98%. So far, GoEasy should have a 100% arrival rate.
3. How about browser compatibility?
In addition to the common browsers chrome, firefox, safari, and opera, it also supports IE 6 to IE11 versions. The lower version of IE browser GoEasy adopts the polling method. GoEasy does a great job of compatibility.
4. Judgment of product stability and security
stability: The project has been running continuously for 4 months, and there has been no situation that news cannot be pushed or received.
Security determination: GoEasy's security control is mainly controlled by appkey. After the app is created, the system will generate two keys, one can be used to receive and push, and the other can only be used to receive. So users can selectively expose your key.
This makes it easy to use PHP to achieve real-time communication between the client and the server.

PHP websocket real-time message push

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=327058830&siteId=291194637