Home > Java > Java Tutorial > body text

JAVA Web real-time message background server push technology---GoEasy

高洛峰
Release: 2016-12-07 15:39:52
Original
1832 people have browsed it

More and more projects require the push and reception of real-time messages. I recommend everyone to use GoEasy, which is a third-party push service platform. You can easily handle real-time push using its API!

Browser compatibility: GoEasy push supports two connection methods: websocket and polling, which can support all versions of IE6 and above, and also supports other browsers such as Firefox, Chrome, Safari, etc.

Supports different development languages: GoEasy Push provides a Restful API interface. No matter which language your background program uses, you can achieve background real-time push through the Restful API. Such as: Java, PHP, C#, Ruby, Python, C, C++, ASP.NET, Node.js...

Supports backend and frontend push: Restful API is used in the backend, and goeasy.js is used in the frontend; very simple to use!

Let me introduce the steps to use GoEasy:

1. You need to register an account on the goeasy official website and create an application. After the application is created, the system will generate two keys for it by default: publish key and subscribe key.

2. Real-time subscription and reception at the front desk

You only need to introduce goeasy.js, and then call goeasy's subscribe method to subscribe to a channel. When subscribing, you can use either publish key or subscribe key. Messages can be received in real time through the callback function of subscribe's parameter onMessage.

3. For front-end real-time push

you still need to introduce goeasy.js (if the page has already been introduced, you can no longer import it), and then call goeasy's publish method to push messages to the subscribed channels. You can only use publish when pushing. key.

4. Backend real-time push

Call GoEasy Restful API, use post method to access http://goeasy.io/goeasy/publish, and also need to bring three necessary parameters:

appkey: publish key

channel: The channel you subscribed to

content: Pushing content

is that simple.

Principle of push: The implementation principle of GoEasy is very simple, that is, one end of the push message is only responsible for pushing, and the pages that need to be received need to be subscribed in advance. What to subscribe to? Subscribe to the channel. When a message is pushed to a certain channel, the client subscribes to the same channel, thus ensuring accurate reception. Through the channel, we can specify which pages or users can receive messages pushed from this channel.

Below I will post a small example I wrote before, which uses Javascript to subscribe, push, receive, and unsubscribe on the web page. The appkey inside is the appkey of goeasy official demo.



GoEasy Test
 




 
 
 

Copy after login

The above is the content of JAVA Web real-time message background server push technology---GoEasy. For more related content, please pay attention to the PHP Chinese website (www.php.cn)!



Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!