Real-time communication with JAVA and Websocket


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 emerge as the times require, and choice has become the biggest problem. Here you may say "why use someone else's, I can develop one myself with the original one." Want to say you are really NB , I'd also love to know how you solved the following problems:
1.         Are you going to spend 1 month, 2 months or 1 year still implementing 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.
Here are a few things to keep in mind when choosing a product:
1. Is the         code structure clear and easy to understand?
2.         How about the message arrival rate and whether the data arrival is visible?
3.         How about browser compatibility
4.         Product stability and safety
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?
The code of GoEasy is divided into two parts: subscription and push:
When subscribing, you only need three lines of code:
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.         How about the message arrival rate and whether the data arrival is visible?
The concurrent user volume of our project is currently at a maximum of 300 people, and 30 messages are pushed every day . The arrival status 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% , and GoEasy should be 100% at present .
3.         How about browser compatibility
In addition to the commonly used browsers chrome, firefox, safari, 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.         Product stability and safety
Judgment of stability: The project has been running continuously for 4 months, and there has been no situation that the 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.
In this way, it is easy to use JAVA to realize real-time communication between the client and the server.
JAVA   websocket real-time message push

Guess you like

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