Implement real-time communication---goeasy with PHP and WebSocket

Source: Internet
Author: User
Tags php websocket

When it comes to websocket we will not be strangers, WebSocket is HTML5 a new agreement. It implements browser-to-server full-duplex communication (Full-duplex). The first handshake needs to be done with an HTTP request, and when the browser and server handshake succeeds, a fast channel is formed between the browser and the server. The data can be transmitted to each other directly between the two. With WebSocket, you can abandon the way you used polling to achieve real-time communication.
With the WebSocket, the emergence of related products are also a few, the choice has become the biggest problem, here you may say, "Why use others, I can use the original development of a AH" on this I just want to say you really NB, I also want to know how you solve the following problems:
1. Do you plan to spend 1 months, 2 months or 1 years to achieve a websocket communication? If you say you plan to spend one months, that means two points, your technology is going to heaven (such a thing you can get out so quickly there is no performance problem, in addition to my existing knees, please take my next life knee also take away), your company local tyrants (your company's hot pursuit of technology has reached the pinnacle of the industry, It seems your project is not very tight, a lot of budget, tell me the name of your company I also come to study technology, haha ha)
2. WebSocket only supports ie10+, Chrome, Firefox, Safari, Opera. Do not say much, the current IE9 and low version of the user community there are many, how do you feel these low-version browser real-time communication?
The above two issues are nothing more than two issues: development costs and browser compatibility issues. From the point of view of managers, all want to compress the development cost as much as possible, all the choice of third-party push service is a rational choice for many enterprises.
The following points need to be taken into consideration when selecting products:
1. Is the code structure clear and understandable?
2. What is the arrival rate of the message and whether the data arrival is visible
3. How browser compatibility
4. Stability and safety of products
Okay, here's the point, I'm not going to judge the pros and cons of other products, just give me a one-sided evaluation of my final choice of products-goeasy push. Goeasy pushes all the metrics I've listed above.
1. Is the code structure clear and understandable?
The Goeasy code is divided into two parts: subscription and push.
When subscribing, you only need three lines of code:
A. Introduction of Goeasy.js (very small file size)
<script type= "Text/javascript" src= "Http://cdn.goeasy.io/goeasy.js" ></script>
B. Creating an Goeasy instance

var goeasy = new Goeasy ({appkey: ' Appkey '});

C. Subscribe to channel.

Goeasy.subscribe ({

Channel: ' Channel1 ',

Onmessage:function (message) {

alert (' meessagereceived: ' +message.content);// receiving a push message

}

});

when pushing, use Goeasy provided by RESTful API to achieve, API only three parameters are required:

URL: http://goeasy.io/goeasy/publish

Method:post

Parameters:appkey, channel, content

2. What is the arrival rate of the message and whether the data arrival is visible
The user concurrency of our project is currently the highest of 300 people, will be pushed 30 messages a day, the arrival of each message can be viewed in the Goeasy background page. As for the arrival rate, our project's requirement for the arrival rate is 98%, so for the time being, the goeasy should be 100% of the arrival rate.
3. How browser compatibility
In addition to the popular browser Chrome, Firefox, Safari, Opera also support IE 6 to IE11 version, the low version of IE browser Goeasy adopted is polling way. Goeasy is doing very well in terms of compatibility.
4. Stability and safety of products
Stability decision: The project has been running for 4 months, there is no message to push out or not receive the situation.
Security decision: Goeasy in the security control is mainly through the Appkey to control, create a good app after the system will generate two keys, one can be used to receive and can be used to push, the other can only be used to receive. So the user can selectively expose your key.
This makes it easy to use PHP for client-server real-time communication.
PHP WebSocket Real-time message push


Implement real-time communication---goeasy with PHP and WebSocket

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.