Implementation of Python based on WebSocket real-time communication-goeasy

Source: Internet
Author: User

Tag: Get message cannot scribe address Pytho func also has sub

Python WebSocket Real-time message push
Here I record how to implement the server-side real-time communication with the client:
The implementation steps are as follows:
1. Get Goeasy Appkey.
Register an account on the Goeasy website and create a new app. After the app is created, the system automatically generates two keys for the app, one that can be used for both receiving and pushing (supper key), and the other to receive (Subscriber key).
2. The client subscribes to a channel.
A. Introducing Goeasy.js to the client, JS address: http://cdn.goeasy.io/goeasy.js
It is important to note that Goeasy.js cannot be downloaded locally, because Goeasy will provide different JS depending on the browser. The official web site also has a corresponding explanation.
B. Subscription code
var goeasy = new Goeasy ({appkey: ' subscriber key '});//I'm using subscriber key here, because I don't need to push any messages on my client, so there's no need to use supper key

Goeasy. Subscribe ({

Channel: ' Csdnnotification ',

Onmessage:function (message) {

Alert (' Meessage received: ' +message.content);//received push message

}

});

3. Push the background to the same channel. RESTful API implementations with Goeasy
API Url:http://goeasy.io/goeasy/publish
Mode: Post
Parameter list:
Channel: ' csdnnotification '//must be consistent with the subscribed channel, otherwise the client will not receive the message. So we can also control which clients can receive according to the channel.
Appkey: ' supper key '//must use supper key here
Content: ' BlaBla ... '//What to push
Hope to be of help to everyone.

Implementation of Python based on WebSocket real-time communication-goeasy

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.