CN104394212A - A method for real-time website push message - Google Patents
A method for real-time website push message Download PDFInfo
- Publication number
- CN104394212A CN104394212A CN201410683166.8A CN201410683166A CN104394212A CN 104394212 A CN104394212 A CN 104394212A CN 201410683166 A CN201410683166 A CN 201410683166A CN 104394212 A CN104394212 A CN 104394212A
- Authority
- CN
- China
- Prior art keywords
- client
- server
- service
- request
- service end
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 238000000034 method Methods 0.000 title claims abstract description 22
- 230000005540 biological transmission Effects 0.000 claims abstract description 4
- 230000000903 blocking effect Effects 0.000 claims 1
- 230000003111 delayed effect Effects 0.000 claims 1
- 238000001514 detection method Methods 0.000 claims 1
- 238000004891 communication Methods 0.000 abstract 1
- 241000282414 Homo sapiens Species 0.000 description 2
- 238000005516 engineering process Methods 0.000 description 2
- 230000003993 interaction Effects 0.000 description 2
- 230000009286 beneficial effect Effects 0.000 description 1
- 230000001934 delay Effects 0.000 description 1
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/50—Network services
- H04L67/55—Push-based network services
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/14—Session management
Landscapes
- Engineering & Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Information Transfer Between Computers (AREA)
- Computer And Data Communications (AREA)
Abstract
Description
技术领域technical field
本发明涉及软件开发技术领域,具体涉及一种实时网站推送消息的方法。The invention relates to the technical field of software development, in particular to a method for pushing messages on a real-time website.
背景技术Background technique
现在是信息化时代,信息化使人类以更快更便捷的方式获得并传递人类创造的一切文明成果。信息的滞后,会带来一些不必要的麻烦,甚至是重大的经济损失。信息的及时性就显得尤为重要,在第一时间对获取的信息作出响应。.Now is the era of information technology, which enables human beings to obtain and deliver all the achievements of civilization created by human beings in a faster and more convenient way. The lag of information will bring some unnecessary troubles and even major economic losses. The timeliness of information is particularly important, and respond to the information obtained in the first time. .
发明内容Contents of the invention
本发明解决的技术问题在于提供一种实时网站推送消息的方法,为用户提供一种及时、高效的获取信息的方法。The technical problem to be solved by the present invention is to provide a method for pushing messages on a real-time website, so as to provide users with a timely and efficient method for obtaining information.
本发明解决上述技术问题的技术方案是:The technical scheme that the present invention solves the problems of the technologies described above is:
通过web客户端发送请求到服务端,服务器端阻塞请求直到有数据传递或超时才返回;之后客户端JavaScript响应处理函数在处理完服务器返回的信息后,再次发出请求,重新建立连接;当客户端处理接收的数据、重新建立连接时,服务器端可能有新的数据到达;这些信息会被服务器端保存直到web客户端重新建立连接;客户端一次将当前服务器端所有的信息取回;从而网站用户可以实时接收到服务端发送的消息,避免消息接收滞后。The request is sent to the server through the web client, and the server blocks the request until there is data transmission or timeout before returning; after the client JavaScript response processing function finishes processing the information returned by the server, it sends the request again and re-establishes the connection; when the client When processing the received data and re-establishing the connection, new data may arrive on the server side; this information will be saved by the server until the web client re-establishes the connection; the client will retrieve all the current server-side information at one time; thus website users The message sent by the server can be received in real time to avoid lagging in message reception.
所述的方法包括如下步骤:Described method comprises the steps:
第1步、首先客户端和服务端交互采用的Bayeux协议;Step 1. First, the Bayeux protocol used by the client and server for interaction;
第2步、客户端向服务端(/meta/handshake频道上)发起握手请求;Step 2, the client initiates a handshake request to the server (on the /meta/handshake channel);
第3步、服务端收到握手请求,BayeuxServer创造了一个半服务器对象的实例;服务端处理完握手请求后,发送响应给客户端;Step 3: The server receives the handshake request, and BayeuxServer creates an instance of a half-server object; after the server finishes processing the handshake request, it sends a response to the client;
第4步、客户端收到服务端处理握手请求的响应,如果成功,则:Step 4. The client receives the response from the server to process the handshake request. If successful, then:
a.向服务端发起订阅服务的请求;a. Initiate a subscription service request to the server;
b.开始与服务端的心跳机制,来交换连接的信息;b. Start the heartbeat mechanism with the server to exchange connection information;
第5步、服务端再启动时初始化两个服务频道Step 5: Initialize two service channels when the server restarts
a./service/privatechat自定义频道a./service/privatechat custom channel
b./service/joinlisten自定义频道b./service/joinlisten custom channel
第6步、客户端向服务端发起订阅/service/privatechat服务,此服务用来实现用户之间的聊天;Step 6: The client initiates a subscription/service/privatechat service to the server, which is used to implement chat between users;
第7步、开始心跳机制;Step 7, start the heartbeat mechanism;
第8步、心跳机制,建立HTTP长轮询;Step 8, heartbeat mechanism, establish HTTP long polling;
第9步、心跳机制,允许客户端检测服务器是否关闭了,并允许服务端检测客户端是否关闭了;Step 9, the heartbeat mechanism allows the client to detect whether the server is closed, and allows the server to detect whether the client is closed;
第10步、客户端和服务器之间的连接的消息一直都有,直至任何一方决定中断并发送一个disconnect的消息;Step 10, the connection message between the client and the server is always there, until either party decides to interrupt and send a disconnect message;
第11步、客户端可以向服务端/service/joinlisten频道发送请求;Step 11, the client can send a request to the server/service/joinlisten channel;
第12步、所有初始化工作都已准备完毕,客户端之间就可以任意发送信息。Step 12, all initialization work has been prepared, and information can be sent between clients arbitrarily.
本发明的有益效果是:通过实时网站推送消息的方法,让用户能及时的获取有用的信息,监控web应用的访问情况,实现及时发现问题、及时处理问题,大大减少客户无法访问应用的时间,把损失降到最低。The beneficial effect of the present invention is: through the method of real-time website pushing messages, users can obtain useful information in time, monitor the access status of web applications, realize timely discovery of problems and timely processing of problems, and greatly reduce the time that customers cannot access applications. Minimize losses.
附图说明Description of drawings
下面结合附图对本发明进一步说明:The present invention is further described below in conjunction with accompanying drawing:
图1为本发明的业务流程图。Fig. 1 is a business flow chart of the present invention.
具体实施方式Detailed ways
见附图所示,本发明通过web客户端发送请求到服务端,服务器端会阻塞请求直到有数据传递或超时才返回,之后客户端JavaScript响应处理函数会在处理完服务器返回的信息后,再次发出请求,重新建立连接。当客户端处理接收的数据、重新建立连接时,服务器端可能有新的数据到达;这些信息会被服务器端保存直到web客户端重新建立连接,客户端会一次把当前服务器端所有的信息取回,让网站用户可以实时接收到服务端发送的消息,避免消息接收滞后,造成的损失!As shown in the attached figure, the present invention sends a request to the server through the web client, and the server will block the request until there is data transmission or timeout before returning, and then the client JavaScript response processing function will process the information returned by the server, and then return to the server again. A request is made to re-establish the connection. When the client processes the received data and re-establishes the connection, new data may arrive on the server; this information will be saved by the server until the web client re-establishes the connection, and the client will retrieve all the current server-side information at one time , so that website users can receive the messages sent by the server in real time, avoiding delays in receiving messages and causing losses!
下面我们以某个推送消息的应用为例,讲述该方法的实施:Let's take an application that pushes messages as an example to describe the implementation of this method:
第1步、首先客户端和服务端交互采用的Bayeux协议;Step 1. First, the Bayeux protocol used by the client and server for interaction;
第2步、客户端向服务端(/meta/handshake频道上)发起握手请求。Bayeux协议要求,一个新的客户端发送的第一条消息是一个握手信息;Step 2: The client initiates a handshake request to the server (on the /meta/handshake channel). The Bayeux protocol requires that the first message sent by a new client is a handshake message;
第3步、服务端收到握手请求,BayeuxServer创造了一个半服务器对象的实例(一个ServerSession)。服务端处理完握手请求后,发送响应给客户端;Step 3, the server receives the handshake request, and BayeuxServer creates an instance of a half-server object (a ServerSession). After the server finishes processing the handshake request, it sends a response to the client;
第4步、客户端收到服务端处理握手请求的响应,如果它是成功,接下来要做两件事情:Step 4. The client receives the response from the server to process the handshake request. If it is successful, the next thing to do is two things:
a.向服务端发起订阅服务的请求。a. Initiate a request to the server to subscribe to the service.
b.开始与服务端的心跳机制,来交换连接的信息;b. Start the heartbeat mechanism with the server to exchange connection information;
第5步、服务端再启动时初始化了两个服务频道Step 5. Two service channels are initialized when the server restarts
a./service/privatechat自定义频道a./service/privatechat custom channel
b./service/joinlisten自定义频道b./service/joinlisten custom channel
第6步、客户端向服务端发起订阅/service/privatechat服务,此服务用来实现用户之间的聊天Step 6: The client initiates a subscription/service/privatechat service to the server, which is used to implement chat between users
第7步、开始心跳机制Step 7, start the heartbeat mechanism
第8步、心跳机制,建立HTTP长轮询。Step 8, heartbeat mechanism, establish HTTP long polling.
第9步、心跳机制,允许客户端检测服务器是否关闭了,并允许服务端检测客户端是否关闭了。Step 9, the heartbeat mechanism allows the client to detect whether the server is closed, and allows the server to detect whether the client is closed.
第10步、客户端和服务器之间的连接的消息一直都有,直至任何一方决定中断并发送一个disconnect的消息(发送/meta/disconnect断开通道消息)Step 10, the connection message between the client and the server has always been there, until either party decides to interrupt and send a disconnect message (send /meta/disconnect disconnect channel message)
第11步、客户端可以向服务端/service/joinlisten频道发送请求Step 11, the client can send a request to the server /service/joinlisten channel
第12步、所有初始化工作都已准备完毕,客户端之间就可以任意发送信息。Step 12, all initialization work has been prepared, and information can be sent between clients arbitrarily.
Claims (2)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201410683166.8A CN104394212A (en) | 2014-11-23 | 2014-11-23 | A method for real-time website push message |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201410683166.8A CN104394212A (en) | 2014-11-23 | 2014-11-23 | A method for real-time website push message |
Publications (1)
Publication Number | Publication Date |
---|---|
CN104394212A true CN104394212A (en) | 2015-03-04 |
Family
ID=52612047
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201410683166.8A Pending CN104394212A (en) | 2014-11-23 | 2014-11-23 | A method for real-time website push message |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN104394212A (en) |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN106850745A (en) * | 2016-12-23 | 2017-06-13 | 北京五八信息技术有限公司 | A kind of real-time synchronization method and device |
CN115103005A (en) * | 2022-06-14 | 2022-09-23 | 北京京东乾石科技有限公司 | Request response method and device, electronic equipment and storage medium |
Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2000041359A1 (en) * | 1998-12-31 | 2000-07-13 | U S West, Inc. | Narrowcast of individual information over a data network |
CN102640449A (en) * | 2009-11-06 | 2012-08-15 | 瑞典爱立信有限公司 | System and methods for web-application communication |
CN103095819A (en) * | 2013-01-04 | 2013-05-08 | 微梦创科网络科技(中国)有限公司 | Data information pushing method and data information pushing system |
-
2014
- 2014-11-23 CN CN201410683166.8A patent/CN104394212A/en active Pending
Patent Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2000041359A1 (en) * | 1998-12-31 | 2000-07-13 | U S West, Inc. | Narrowcast of individual information over a data network |
CN102640449A (en) * | 2009-11-06 | 2012-08-15 | 瑞典爱立信有限公司 | System and methods for web-application communication |
CN103095819A (en) * | 2013-01-04 | 2013-05-08 | 微梦创科网络科技(中国)有限公司 | Data information pushing method and data information pushing system |
Non-Patent Citations (2)
Title |
---|
吴亚峰 等: "用Ajax+Comet轻松实现实时Web聊天系统", 《网络与通信》 * |
孙清国 等: "Web应用中的服务器推送技术研究综述", 《计算机系统应用》 * |
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN106850745A (en) * | 2016-12-23 | 2017-06-13 | 北京五八信息技术有限公司 | A kind of real-time synchronization method and device |
CN106850745B (en) * | 2016-12-23 | 2021-01-15 | 北京五八信息技术有限公司 | Real-time synchronization method and device |
CN115103005A (en) * | 2022-06-14 | 2022-09-23 | 北京京东乾石科技有限公司 | Request response method and device, electronic equipment and storage medium |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
EP2638680B1 (en) | Full-duplex bi-directional communication over a remote procedure call based communications protocol, and applications thereof | |
US10027781B2 (en) | TCP link configuration method, apparatus, and device | |
CN103535004B (en) | Method and web-based system for facilitating anonymous audio and video communications | |
EP2688307A1 (en) | Wireless communication system for offline participation in a display session | |
KR102208935B1 (en) | Messaging api over http protocol to establish context for data exchange | |
HK1208970A1 (en) | Processing method, device and system for message service and message service system | |
CN105610888A (en) | Method of using socket to push message based on Android and system thereof | |
EP2991318B1 (en) | Hybrid cloud architecture for media communications | |
WO2015180570A1 (en) | Data channel establishment method and communications device | |
CN107258098A (en) | Method and apparatus for the shared abundant information associated with calling | |
CN106941536A (en) | Data interactive method between client and server based on http protocol | |
CN108683653A (en) | A kind of active message push system based on WebSocket | |
CN106936730A (en) | A kind of file transmitting method, TCP agent and TCP Client | |
CN104320328A (en) | Message synchronization method, terminal and server | |
CN104486327A (en) | Method and client side of communication between pages and long connection servers | |
WO2023150609A3 (en) | Intelligent edge enabler client operation | |
CN110113623B (en) | An audio and video slice transmission platform based on SIP protocol | |
EP2966832A2 (en) | Multimedia conversation transfer | |
US20170359187A1 (en) | Scalable real-time videoconferencing over WebRTC | |
CN102065143B (en) | Communication method and system based on HTTP (hyper Text Transfer Protocol), HTTP server and HTTP client | |
CN105743852B (en) | Method and system for realizing Socket connection maintaining communication across network gate through http | |
CN104394212A (en) | A method for real-time website push message | |
US9137104B2 (en) | Method and apparatus of performing remote management of a managed machine | |
WO2014117506A1 (en) | Method and device for sending multimedia message to group member | |
CN104995898A (en) | Method, device and system for establishing data channel |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
WD01 | Invention patent application deemed withdrawn after publication |
Application publication date: 20150304 |
|
WD01 | Invention patent application deemed withdrawn after publication |