JAVA Web Real-time message Background server Push technology---goeasy_javascript skills

Source: Internet
Author: User
Tags java web

More and more projects need to use real-time message push and receive, I recommend that you use Goeasy, it is a third-party push service platform, the use of its API can easily handle real-time push!

Browser compatibility: Goeasy push supports websocket and polling two ways to support IE6 and all versions above it, while supporting other browsers such as Firefox, Chrome, Safari, and more.

Support for different development languages: Goeasy push provides restful API interface, no matter what language you use in the background program can be implemented through the RESTful API real-time push. such as: java,php, C #, Ruby, Python, C, C + +, asp.net,node.js ...

Support backstage and foreground push: Backstage uses restful API, foreground uses goeasy.js; The application is very simple!

Let me introduce the following 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 Key:publish key and subscribe key by default.

2. Front-desk subscription and reception

Only need to introduce goeasy.js, and then call the Goeasy Subscribe method to subscribe to a channel, subscribe to either the Publish key or the Subscribe key can be. A callback function that is onmessage by subscribe parameters can receive messages in real time.

3. Front-desk push

It is also necessary to introduce goeasy.js (if the page has been introduced and not introduced), and then invoke the Goeasy publish method to push messages to the subscribed channel, which can only be used with the publish key.

4. Background real-time push

Call the Goeasy Restful API, post-access http://goeasy.io/goeasy/publish, and take three necessary parameters:

    • Appkey:publish Key
    • Channel: You subscribed to the channel
    • Content: Push Contents

It's so simple.

The principle of the push: the principle of goeasy is very simple, that is, push the message at one end is responsible for the push, and the need to receive the pages need to subscribe in advance. What do you subscribe to? Subscribe to channel. To push messages to a channel, the client subscribes to the same channel, which ensures accurate reception. By channel we can specify which pages or which users can receive messages that are pushed from this channel.

Below I post a small instance of the previous one, which uses JavaScript to subscribe to the Web page, push, receive, and unsubscribe examples, where the appkey with the Goeasy official demo Appkey.

 

The above is the entire content of this article, I hope to help you learn, but also hope that we support the cloud habitat community.

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.