CN108809821A - A kind of instant communicating method based on message cloud - Google Patents
A kind of instant communicating method based on message cloud Download PDFInfo
- Publication number
- CN108809821A CN108809821A CN201811027113.5A CN201811027113A CN108809821A CN 108809821 A CN108809821 A CN 108809821A CN 201811027113 A CN201811027113 A CN 201811027113A CN 108809821 A CN108809821 A CN 108809821A
- Authority
- CN
- China
- Prior art keywords
- message
- cloud
- receiving thread
- background server
- message cloud
- 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
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L51/00—User-to-user messaging in packet-switching networks, transmitted according to store-and-forward or real-time protocols, e.g. e-mail
- H04L51/04—Real-time or near real-time messaging, e.g. instant messaging [IM]
- H04L51/046—Interoperability with other network applications or services
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L51/00—User-to-user messaging in packet-switching networks, transmitted according to store-and-forward or real-time protocols, e.g. e-mail
- H04L51/21—Monitoring or handling of messages
- H04L51/214—Monitoring or handling of messages using selective forwarding
-
- 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/01—Protocols
- H04L67/02—Protocols based on web technology, e.g. hypertext transfer protocol [HTTP]
-
- 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/01—Protocols
- H04L67/10—Protocols in which an application is distributed across nodes in the network
-
- 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
- H04L67/141—Setup of application sessions
-
- 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
- H04L67/146—Markers for unambiguous identification of a particular session, e.g. session cookie or URL-encoding
-
- 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
- H04L69/00—Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
- H04L69/16—Implementation or adaptation of Internet protocol [IP], of transmission control protocol [TCP] or of user datagram protocol [UDP]
- H04L69/161—Implementation details of TCP/IP or UDP/IP stack architecture; Specification of modified or new header fields
- H04L69/162—Implementation details of TCP/IP or UDP/IP stack architecture; Specification of modified or new header fields involving adaptations of sockets based mechanisms
Landscapes
- Engineering & Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Computer Security & Cryptography (AREA)
- Information Transfer Between Computers (AREA)
- Computer And Data Communications (AREA)
Abstract
The invention discloses a kind of instant communicating methods based on message cloud, including:Step S100:Server is logged in using the message cloud ID on background server to message cloud registration message cloud ID, is established and is connected with message cloud;Step S200:Websocket connections are established between background server and foreground browser page;Step S300:Background server is that each websocket connections start a receiving thread, and the receiving thread is used to receive the message of message cloud active push;Step S400:Receiving thread parses the message received according to the message format of setting, filters out effective information and active push to foreground browser page.The present invention is attached using websocket protocol, greatly reduces the pressure of server, and when background server receives the request of message cloud, and meeting active push to foreground browser page, such foreground browser page can timely receive message.
Description
Technical field
The present invention relates to fields of communication technology, are a kind of instant communicating methods based on message cloud specifically.
Background technology
Now, many websites are all polls to realize push technology, technology used.Poll is between the specific time
Every sending out HTTP request to server by browser, then return to browsing of the newest data to client by server
Device.This traditional banding carrys out apparent disadvantage, i.e., browser needs constantly to send out request to server, however HTTP
The header of request is very long, and the data that the inside includes may be the value of a very little, can be occupied so very much
Bandwidth and server resource.And the effect that newer technology does poll is Comet, has used AJAX.Though but this technology
Two-way communication so is can reach, but still needs to send out request, and in Comet, generally uses long link, this also can be a large amount of
Server bandwidth and resource are consumed, has seriously affected the performance of server, and due to being that browser is actively carried out to server
Http request can lead to the arrival not in time of message.
Invention content
The purpose of the present invention is to provide a kind of instant communicating methods based on message cloud, are adopted in the prior art for solving
The problem of server resource being occupied with training in rotation mode, influencing server performance and message sink not in time.
The present invention is solved the above problems by following technical proposals:
A kind of instant communicating method based on message cloud, including:
Step S100:Server is stepped on using the message cloud ID on background server to message cloud registration message cloud ID
Record is established with message cloud and is connected;
Step S200:Websocket connections are established between background server and foreground browser page;
Step S300:Background server is that each websocket connections start a receiving thread, and the receiving thread is used
In the message for receiving message cloud active push;
Step S400:Receiving thread parses the message received according to the message format of setting, filters out effectively
Information and active push to foreground browser page.
Foreground browser page is established websocket after shaking hands by a HTTP with background server and is connect, and backstage takes
Business end can know always the information of foreground browser page, until foreground browser page turn-off request, avoid so anti-
The problem of parsing http protocol again, greatly reduces the pressure of server, and when background server receives asking for message cloud
When asking, meeting active push to foreground browser page, such foreground browser page can timely receive message.
Further, the receiving thread uses Observer Pattern, each receiving thread to be respectively provided with as observed person
Corresponding monitoring thread is as observer, and the monitoring thread when receiving thread exits extremely for being re-registered, again
Open thread.
After wrong information being received due to thread, it may appear that abnormal case causes the receiving thread to exit, Wu Faji
Continued access receives the message of message cloud.So being directed to receiving thread, keep-alive is carried out using Observer Pattern to it.Receiving thread
As observed person, another receiving thread monitors thread as observer, is exited when exception occurs in receiving thread, by monitoring line
Cheng Jinhang is restarted, and ensures websocket connections survival.
Further, further include in the step S300:Background server is that a mark is established in each websocket connections
Know ID.
Further, in the step S400, background server is sent to according to the mark ID of websocket connections
Corresponding foreground browser page.
Each websocket connection is both provided with mark ID, after the message that background server receives the push of message cloud,
It is pushed according to mark ID, message is allow accurately, quickly to push.
Compared with prior art, the present invention haing the following advantages and advantageous effect:
(1) the websocket connections in the present invention only need a HTTP to shake hands, i.e., entire communication process is built upon one
In secondary connection/state, the non-state of HTTP is avoided, background server can know always the information of foreground browser page,
Until foreground browser page turn-off request, the problem of avoiding iterative parsing http protocol in this way.
(2) present invention is attached using websocket protocol, greatly reduces the pressure of server, and when backstage
When server receives the request of message cloud, meeting active push to foreground browser page, such foreground browser page energy
Timely receive message.
Description of the drawings
Fig. 1 is the systematic schematic diagram of the present invention;
Fig. 2 is the flow chart of Observer Pattern of the present invention.
Specific implementation mode
The present invention is described in further detail with reference to embodiment, embodiments of the present invention are not limited thereto.
Embodiment 1:
In conjunction with shown in attached drawing 1, a kind of instant communicating method based on message cloud, including:
Step S100:Server is stepped on using the message cloud ID on background server to message cloud registration message cloud ID
Record is established with message cloud and is connected;
Step S200:Websocket connections are established between background server and foreground browser page;
Step S300:Background server is that each websocket connections start a receiving thread, and the receiving thread is used
In the message for receiving message cloud active push, background server is that a mark ID is established in each websocket connections;
Step S400:Receiving thread parses the message received according to the message format of setting, filters out effectively
Information and carry out active push to corresponding foreground browser page according to the mark ID of websocket connections.
Foreground browser page is established websocket after shaking hands by a HTTP with background server and is connect, and backstage takes
Business end can know always the information of foreground browser page, until foreground browser page turn-off request, avoid so anti-
The problem of parsing http protocol again, greatly reduces the pressure of server, and when background server receives asking for message cloud
When asking, meeting active push to foreground browser page, such foreground browser page can timely receive message.Each
Websocket connections be both provided with mark ID, background server receive message cloud push message after, according to mark ID into
Row push, allows message accurately, quickly to push.
Embodiment 2:
On the basis of embodiment 1, in conjunction with shown in Fig. 2, receiving thread uses Observer Pattern, each receiving thread to make
For observed person, corresponding monitoring thread is respectively provided with as observer, the monitoring thread for exiting extremely in receiving thread
Shi Jinhang is re-registered, is restarted thread.
After wrong information being received due to thread, it may appear that abnormal case causes the receiving thread to exit, Wu Faji
Continued access receives the message of message cloud.So being directed to receiving thread, keep-alive is carried out using Observer Pattern to it.Receiving thread
As observed person, another receiving thread monitors thread as observer, is exited when exception occurs in receiving thread, by monitoring line
Cheng Jinhang is restarted, and ensures websocket connections survival.
Although reference be made herein to invention has been described for explanatory embodiment of the invention, and above-described embodiment is only this hair
Bright preferable embodiment, embodiment of the present invention are not limited by the above embodiments, it should be appreciated that people in the art
Member can be designed that a lot of other modification and implementations, these modifications and implementations will be fallen in principle disclosed in the present application
Within scope and spirit.
Claims (4)
1. a kind of instant communicating method based on message cloud, which is characterized in that including:
Step S100:Server is logged in using the message cloud ID on background server to message cloud registration message cloud ID, with
Message cloud establishes connection;
Step S200:Websocket connections are established between background server and foreground browser page;
Step S300:Background server is that each websocket connections start a receiving thread, and the receiving thread is for connecing
Receive the message of message cloud active push;
Step S400:Receiving thread parses the message received according to the message format of setting, filters out effective letter
It ceases and active push is to foreground browser page.
2. a kind of instant communicating method based on message cloud according to claim 1, which is characterized in that the receiving thread
Using Observer Pattern, each receiving thread is respectively provided with corresponding monitoring thread as observer as observed person, described
Monitoring thread when receiving thread exits extremely for carrying out restarting receiving thread.
3. a kind of instant communicating method based on message cloud according to claim 1, which is characterized in that the step S300
In further include:Background server is that a mark ID is established in each websocket connections.
4. a kind of instant communicating method based on message cloud according to claim 3, which is characterized in that the step S400
In, background server carries out being sent to corresponding foreground browser page according to the mark ID of websocket connections.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201811027113.5A CN108809821A (en) | 2018-09-04 | 2018-09-04 | A kind of instant communicating method based on message cloud |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201811027113.5A CN108809821A (en) | 2018-09-04 | 2018-09-04 | A kind of instant communicating method based on message cloud |
Publications (1)
Publication Number | Publication Date |
---|---|
CN108809821A true CN108809821A (en) | 2018-11-13 |
Family
ID=64081583
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201811027113.5A Pending CN108809821A (en) | 2018-09-04 | 2018-09-04 | A kind of instant communicating method based on message cloud |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN108809821A (en) |
Cited By (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109462544A (en) * | 2018-11-16 | 2019-03-12 | 贵阳朗玛信息技术股份有限公司 | The method and device of instant messaging, instant communicating system, readable storage medium storing program for executing |
CN109660603A (en) * | 2018-11-27 | 2019-04-19 | 浙江万朋教育科技股份有限公司 | A method of it realizes immediately or timing controlled remote device data is shown |
CN110417865A (en) * | 2019-06-28 | 2019-11-05 | 苏州浪潮智能科技有限公司 | A kind of method and apparatus that resource is found automatically |
CN111222074A (en) * | 2020-01-09 | 2020-06-02 | 山东汇贸电子口岸有限公司 | Message pushing method and system based on Websocket protocol |
CN112653747A (en) * | 2020-12-17 | 2021-04-13 | 青岛以萨数据技术有限公司 | Communication method, system and storage medium based on B/S architecture |
Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103825759A (en) * | 2014-02-13 | 2014-05-28 | 北京百度网讯科技有限公司 | Method and system for acquiring network topological information |
CN107592324A (en) * | 2016-07-06 | 2018-01-16 | 广州市动景计算机科技有限公司 | Information push method and device and portable terminal |
-
2018
- 2018-09-04 CN CN201811027113.5A patent/CN108809821A/en active Pending
Patent Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103825759A (en) * | 2014-02-13 | 2014-05-28 | 北京百度网讯科技有限公司 | Method and system for acquiring network topological information |
CN107592324A (en) * | 2016-07-06 | 2018-01-16 | 广州市动景计算机科技有限公司 | Information push method and device and portable terminal |
Non-Patent Citations (1)
Title |
---|
杜风旭: ""基于WebSocket协议的在线聊天系统设计与实现"", 《中国优秀硕士学位论文全文数据库(电子期刊)》 * |
Cited By (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109462544A (en) * | 2018-11-16 | 2019-03-12 | 贵阳朗玛信息技术股份有限公司 | The method and device of instant messaging, instant communicating system, readable storage medium storing program for executing |
CN109660603A (en) * | 2018-11-27 | 2019-04-19 | 浙江万朋教育科技股份有限公司 | A method of it realizes immediately or timing controlled remote device data is shown |
CN110417865A (en) * | 2019-06-28 | 2019-11-05 | 苏州浪潮智能科技有限公司 | A kind of method and apparatus that resource is found automatically |
CN111222074A (en) * | 2020-01-09 | 2020-06-02 | 山东汇贸电子口岸有限公司 | Message pushing method and system based on Websocket protocol |
CN112653747A (en) * | 2020-12-17 | 2021-04-13 | 青岛以萨数据技术有限公司 | Communication method, system and storage medium based on B/S architecture |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN108809821A (en) | A kind of instant communicating method based on message cloud | |
CN106453288B (en) | A kind of distributed micro services frame system that supporting asynchronous mode and its implementation | |
CN104660708B (en) | A kind of Mobile solution information push method and system based on HTTP | |
CN101843076B (en) | Method and apparatus for peer to peer link establishment over a network | |
US9203684B1 (en) | Reduction of web page load time using HTTP header compression | |
JP6226348B2 (en) | Method for transmitting heartbeat message and portable terminal | |
CN106031222A (en) | Queueing mechanism for client-side network traffic to reduce radio power consumption on mobile clients | |
CN104917833A (en) | Asynchronous information processing method based on NIO request | |
KR20160060723A (en) | Service agent method, modem and terminal | |
CN109327493A (en) | A kind of remote medical monitoring system based on cloud and monitoring method | |
CN103428198B (en) | network device, system and method | |
CN108551668B (en) | Information transmission method, device, equipment and storage medium | |
CN112631788B (en) | Data transmission method and data transmission server | |
EP3706449A3 (en) | Electronic device for transmitting response message in bluetooth network environment | |
CN103780681A (en) | High real-time Web application system and data real-time pushing method thereof | |
CN107659414A (en) | Remote wakening system and method based on P2P | |
WO2016095323A1 (en) | Data transmission method and apparatus based on serial server | |
CN104735151A (en) | Process bar control method, device and system | |
CN104994181B (en) | A kind of method that dynamic MAC address table is shown in distributed OLT system | |
JP2014057149A (en) | Communication device, relay device and communication method | |
CN108632136A (en) | Patrol river data processing method and device | |
CN104348713A (en) | Instant messaging method based on comet of network platform under B/S (Browser/Server) architecture | |
CN111064768B (en) | Printer data transmission control method, device, equipment and storage medium | |
US20170111256A1 (en) | Hierarchical query response limiter | |
CN104506642B (en) | A kind of efficient transmitting-receiving of client message and processing method and system |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20181113 |
|
RJ01 | Rejection of invention patent application after publication |