Java message push------goeasy for server-side push and web-side push

Source: Internet
Author: User

Project needs to push the message, but also want to lower development costs, specific requirements: role users in the background Management page to publish a message, all users of this system on any page can receive his message in a timely manner, and then I on the internet to find a third party free push service-goeasy push, It can meet my needs, below is how to use goeasy for information push and receive:

The first type: Java server-side push, web-side receive push information

Steps:

从GoEasy官网下载jar包,并放到项目中。

Https://cdn.goeasy.io/sdk/goeasy-0.1.jar

    1. Java code comes, you do not read wrong, only two lines of code:

Goeasy goeasy = Goeasy ("Your App key");
Goeasy.publish ("Your_channel", "your Message");

How do I get appkey?

Register and activate your account on the Goeasy website, then you can log in to the backend system to add application yourself, after adding application, the system will automatically help you generate Appkey, and then you can use.

The push is complete, and here's how to receive the push message.

    1. Introduction of Goeasy.js

      <script type= "Text/javascript" src= "Https://cdn.goeasy.io/goeasy.js" ></script>

    2. Initializing the Goeasy object

      <script type= "Text/javascript" >
      var goeasy = new Goeasy ({
      Appkey: ' Your app key here '
      });

</script>

5.JS Subscribe to Channel

Goeasy.subscribe ({
Channel: ' Your_channel ',
Onmessage:function (message) {//auto receive push message
Alert (' Meessage received: ' +message.content);
}
});

It is important to note that only when the channel of the subscription is consistent with the channel of the push will it be received correctly! (the principle is similar to the frequency of radio!) )

The implementation is complete!

The second type: Web-side push, web-side receive push information

Steps:

    1. Introduction of Goeasy.js

      <script type= "Text/javascript" src= "Https://cdn.goeasy.io/goeasy.js" ></script>

    2. Initializing the Goeasy object

      <script type= "Text/javascript" >
      var goeasy = new Goeasy ({
      Appkey: ' Your app key here '
      });

</script>

    1. JS Push message:

      Goeasy.publish ({
      Channel: ' Your_channel ',
      Message: ' Hello world! ' The information you want to push
      });

    2. JS subscription information

      Goeasy.subscribe ({
      Channel: ' Your_channel ',
      Onmessage:function (message) {//auto receive push message
      Alert (' Meessage received: ' +message.content);
      }
      });

The code is very simple and does not require a variety of configurations!

Goeasy Official website: Https://goeasy.io

Quick Start: https://goeasy.io/www/started.jsp

Document: https://goeasy.io/www/docs.jsp

Java message push------goeasy for server-side push and web-side push

Related Article

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.