CN114172945A - Method and equipment for realizing full-duplex instant messaging by simulation - Google Patents
Method and equipment for realizing full-duplex instant messaging by simulation Download PDFInfo
- Publication number
- CN114172945A CN114172945A CN202111438972.5A CN202111438972A CN114172945A CN 114172945 A CN114172945 A CN 114172945A CN 202111438972 A CN202111438972 A CN 202111438972A CN 114172945 A CN114172945 A CN 114172945A
- Authority
- CN
- China
- Prior art keywords
- http request
- type
- client
- server
- duplex
- 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.)
- Granted
Links
Images
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/14—Session management
- H04L67/141—Setup of application sessions
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L5/00—Arrangements affording multiple use of the transmission path
- H04L5/14—Two-way operation using the same type of signal, i.e. duplex
-
- 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]
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02D—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
- Y02D30/00—Reducing energy consumption in communication networks
- Y02D30/50—Reducing energy consumption in communication networks in wire-line communication networks, e.g. low power modes or reduced link rate
Abstract
The application discloses a method and a device for realizing full-duplex instant messaging by simulation, wherein the method comprises the following steps: receiving an HTTP request sent by a client through a server; if the HTTP request is a first-class HTTP request, the server responds to the first-class HTTP request and establishes SSE connection with the client; if the HTTP request is a second type HTTP request, the server side sends a processing result of the second type HTTP request to the client side through the SSE connection, so that full duplex real-time communication can be simulated under the condition that a port of the server side is limited, the real-time performance of communication is improved, and the resource waste of a server is reduced.
Description
Technical Field
The present application relates to the field of information communication technologies, and in particular, to a method and a computer device for implementing full-duplex instant messaging in a simulated manner.
Background
The conventional method for realizing duplex instant messaging adopts a full-duplex WebSocket scheme, which requires a server to monitor a specific port of a device, a client to initiate connection to the port, and the server and the client can push data mutually after the connection is established. However, when the server is a virtual host, the virtual host is usually a hypertext preprocessor php environment or an active server webpage asp environment, and in a scenario where ports of the virtual host are limited, only 80 or 443 ports are used for receiving HTTP (hypertext Transfer Protocol) requests, and meanwhile, the service cannot be started to monitor other ports, so the WebSocket technology cannot be used in the scenario.
In the prior art, under the condition that the WebSocket technology cannot be used, the scheme adopted for realizing the duplex communication is a polling or long connection technology. The polling refers to that a client inquires whether a new message exists from a server side through an HTTP request at regular time, but if the polling interval is too long, the message is not timely, and if the interval is too short, the server is requested too much, so that the burden is increased. The long connection technology is an improvement on the polling technology, a client initiates an HTTP request to a server regularly, but the connection is maintained until a message is returned, the long connection is continuously initiated, the HTTP request is waited by the long connection mode until a data range exists, server resources are greatly wasted, and the long connection technology is not recommended in actual use. Therefore, it is necessary to provide a method for implementing full-duplex instant messaging by simulation under the condition of limited virtual machine port.
Disclosure of Invention
The application mainly aims to provide a method for realizing full-duplex instant messaging in a simulation mode and computer equipment, and aims to solve the technical problem that servers like virtual hosts cannot perform instant full-duplex communication under the condition that ports are limited.
In a first aspect, the present application provides a method for simulating and implementing full-duplex instant messaging, the method comprising the following steps:
the server receives an HTTP request sent by the client;
if the HTTP request is a first-class HTTP request, the server responds to the first-class HTTP request and establishes SSE connection with the client;
and if the HTTP request is a second type HTTP request, the server side sends a processing result of the second type HTTP request to the client side through the SSE connection.
In some embodiments, if the HTTP request is a first type HTTP request, after the server side responds to the first type HTTP request and establishes an SSE connection with the client side, the method includes:
the server side circularly reads the second type of HTTP requests within set time;
if the second type HTTP request is read, processing the second type HTTP request, and sending a processing result of the second type HTTP request to the client through the SSE connection;
and if the second type of HTTP request is not read, stopping circularly reading the second type of HTTP request, and closing the SSE connection.
In some embodiments, if the second type of HTTP request is not read, stopping reading the second type of HTTP request in a loop, and closing the SSE connection includes:
the server side does not read the second type HTTP request in one reading, sends an empty information packet to the client side through the SSE connection so as to maintain the SSE connection with the client side, and subtracts a first preset time from the rest of the set time;
and after the set time is over, stopping circularly reading the second type of HTTP request, and closing the SSE connection.
In some embodiments, if the second type HTTP request is read, processing the second type HTTP request, and sending a processing result of the second type HTTP request to the client through the SSE connection includes:
the server side circularly reads the second type of HTTP requests within set time;
if the second type of HTTP request is read within the set time, resetting the set time, processing the second type of HTTP request, and sending the processing result of the second type of HTTP request to the client through the SSE connection; and the number of the first and second electrodes,
and after the set time is reset, carrying out cyclic reading within the set time after the resetting, and separating a second preset time between two adjacent readings within the same set time, wherein the second preset time is increased along with the increase of the reading times.
In some embodiments, if the HTTP request is a second type HTTP request, the method further includes:
and the server caches the information of the second type of HTTP request to form cached information of the second type of HTTP request.
In some embodiments, if the HTTP request is a second type HTTP request, the server caches the second type HTTP request information to form cached information, further including:
determining whether a cache file corresponding to the second type of HTTP request exists;
if a cache file corresponding to the second type of HTTP request exists, caching the second type of HTTP request in the cache file;
if the cache file corresponding to the second type HTTP request does not exist, establishing the cache file corresponding to the second type HTTP request, and caching the second type HTTP request into the cache file.
In some embodiments, the creating a cache file corresponding to a source according to the source of the second type HTTP request includes:
establishing a first-layer directory according to the identification of the client;
establishing a second-layer directory under the first-layer directory according to the sending channel type of the second HTTP request;
and establishing a cache file positioned under the second-layer directory according to the timestamp of the second-type HTTP request.
In some embodiments, the simulating method for implementing full-duplex instant messaging further includes cyclically reading the cached information within a set time, and includes:
traversing all the cache files in a layer of directory corresponding to the identification of the client in one reading;
if the cache information exists in the cache file, exporting the cache information, and emptying the cache file;
and if the cache message does not exist in the cache file, deleting the cache file.
In a second aspect, the present application also provides a computer device comprising a processor, a memory, and a computer program stored on the memory and executable by the processor, wherein the computer program, when executed by the processor, implements the steps of the method for simulating full-duplex instant messaging according to the first aspect.
In a third aspect, the present application further includes a method for implementing full-duplex instant messaging by simulation, which is characterized by comprising:
the client sends a first type HTTP request for requesting to establish SSE connection to the server;
the client sends a second type HTTP request to the server;
after the SSE connection is established between the server and the client, the client receives a second type HTTP request processing result fed back by the server through the SSE connection.
In a fourth aspect, the present application also provides a computer device comprising a processor, a memory, and a computer program stored on the memory and executable by the processor, wherein the computer program, when executed by the processor, implements the steps of the method for simulating full-duplex instant messaging according to the third aspect.
The application provides a method for simulating and realizing full-duplex instant messaging and computer equipment, wherein an HTTP request sent by a client is received through a server; if the HTTP request is a first-class HTTP request, the server responds to the first-class HTTP request and establishes SSE connection with the client; if the HTTP request is a second type HTTP request, the server side sends a processing result of the second type HTTP request to the client side through the SSE connection, so that full duplex real-time communication can be simulated under the condition that a port of the server side is limited, the real-time performance of communication is improved, and the resource waste of a server is reduced.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings needed to be used in the description of the embodiments are briefly introduced below, and it is obvious that the drawings in the following description are some embodiments of the present application, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without creative efforts.
Fig. 1 is a schematic flowchart of a server for simulating a method for implementing full-duplex instant messaging according to an embodiment of the present disclosure;
fig. 2 is a specific flowchart of a method for implementing simulation of implementing full-duplex instant messaging by a server;
fig. 3 is a schematic flowchart illustrating a client simulating a full-duplex instant messaging method according to an embodiment of the present disclosure;
fig. 4 is a block diagram schematically illustrating a structure of a computer device according to an embodiment of the present application.
The implementation, functional features and advantages of the objectives of the present application will be further explained with reference to the accompanying drawings.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are some, but not all, embodiments of the present application. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
The flow diagrams depicted in the figures are merely illustrative and do not necessarily include all of the elements and operations/steps, nor do they necessarily have to be performed in the order depicted. For example, some operations/steps may be decomposed, combined or partially combined, so that the actual execution sequence may be changed according to the actual situation.
The embodiment of the application provides a method for realizing full-duplex instant messaging in a simulation mode and computer equipment.
Some embodiments of the present application will be described in detail below with reference to the accompanying drawings. The embodiments described below and the features of the embodiments can be combined with each other without conflict.
It should be noted that HTTP in this document is hypertext Transfer Protocol (hypertext Transfer Protocol), and SSE in this document is server push Event (server-server Event).
Referring to fig. 1, fig. 1 is a schematic flowchart illustrating a server simulating a method for implementing full-duplex instant messaging according to an embodiment of the present disclosure.
As shown in fig. 1, the method includes steps S101 to S103.
Step S101, the server receives the HTTP request sent by the client.
Illustratively, the received HTTP requests are classified into a first type of HTTP request and a second type of HTTP request. The first type of HTTP request is a GET type HTTP request with a request for establishing SSE connection, and the second type of HTTP request is a POST type HTTP request with a common interactive request.
Step S102, if the HTTP request is a first type HTTP request, the server side responds to the first type HTTP request and establishes SSE connection with the client side.
Step S103, if the HTTP request is a second type HTTP request, the server side sends a processing result of the second type HTTP request to the client side through the SSE connection.
It should be noted that, after the server and the client form the SSE connection, the server can actively send information to the server through the SSE connection due to the characteristics of the SSE connection. Therefore, the server only needs one port to receive different HTTP requests in real time under the condition that the port is limited, and after the received HTTP requests are processed, other ports are not needed when information is returned, the processing result can be returned to the client through SSE connection, so that the simulation of full duplex is realized under the condition that the port is limited by the server, and a specific implementation mode is described below.
In some embodiments, referring to fig. 2, if the request received by the server is a first HTTP request, that is, a GET request, the server establishes an SSE connection with the client. If the request received by the server is a second-class HTTP request, namely a POST request, the server caches the second-class HTTP request into a cache file according to the identification and information of the second-class HTTP request to form cache information of the second-class HTTP request. The server establishes SSE connection or forms cache information without sequence, and corresponding processing is carried out according to the type of the HTTP request as long as the HTTP request is received.
After SSE connection is established, the SSE connection maintains set time, the server circularly reads cache information formed by the cached second-class HTTP request in the set time, processes the cache information if the cache information is read, and sends a processing result of the cache information to the client through the SSE connection; if the cache information is not read within the set time, the cycle reading is stopped after the set time is over.
As a preferred embodiment, please refer to fig. 2, in which if no cache information is read within a set time, the loop reading is stopped after the set time is over, the method includes the following steps: when the server side circularly reads, cache information is not read in one-time reading, no HTTP request needs to be processed at the moment, the server side sends an empty information packet, namely a heartbeat packet to the client side so as to maintain SSE connection with the client side, in addition, the first preset time is subtracted from the rest set time, no cache information is read after the set time is over, the SSE connection is disconnected by the server side, resources are released, and the circular reading is stopped at the same time.
As a preferred embodiment, please refer to fig. 2, if the cache information is read, the cache information is processed, and a processing result of the cache information is sent to the client through the SSE connection, which further includes the specific steps; the server reads the cache information in the set time of cyclic reading, resets the set time, and performs cyclic reading in the set time after resetting. And meanwhile, processing the cache information, and sending the processing result of the second type of HTTP request to the client through SSE connection.
And a second preset time is set to be set between two adjacent cyclic readings in the same set time slice, the second preset time in this embodiment is 0.5 second, and the second preset time is a sleep time of the server after one reading, so as to avoid the problem of dead cycle caused by overlapping of two readings, and achieve the purpose of optimizing the reading performance of the cache information.
The second predetermined time will also increase with the increase of the number of readings within the same set time, for example, the second predetermined time after the first reading after the reset of the set time is 0.5 seconds, the second predetermined time after the second reading is 0.6 seconds, and so on. This is because the sleep time for setting reading is short just after the setting time is reset, so as to ensure the timeliness of the message. Because the second preset time is the sleep time, the second preset time can be set not to be included in the set time, so that the sleep time is synchronously increased along with the increase of the reading times, the existence time of the SSE connection can be prolonged, and more processing results of the HTTP requests can be returned to the client through the SSE connection in the connection.
Further, when the cache information is processed, the processing result of the second type of HTTP request is sent to the client through the SSE connection, which specifically includes: the server reads the cache information, calls a business processing flow of the cache information when reading the cache information once, performs corresponding business processing on the cache information in the business processing flow by the user, and completes sending by using the information sending function of the server through SSE connection when needing to send information to the client.
It should be noted that, while the server sends the processing result of the cache information to the client, the server also sends the information occurring in real time and the remaining set time to the client, and optionally tells the client how long time the SSE connection is disconnected to initiate a request for reconnection again to establish a new SSE connection. Therefore, the performance of the server can be optimized on the premise of ensuring the timely efficiency of the message, if the message is dense, the request is maintained for a long time, the message is ensured to be sent in time, if the message is sparse, the request is interrupted, and the resource is released to relieve the pressure of the server.
In some embodiments, the server caches the second type HTTP request in a cache file according to the identifier and information of the second type HTTP request to form cache information of the second type HTTP request, and the specific implementation includes the following steps: determining whether a cache file corresponding to the identification and the information of the second type HTTP request exists, and if the cache file corresponding to the identification and the information of the second type HTTP request exists, directly caching the second type HTTP request in the corresponding cache file; and if the corresponding cache file does not exist, establishing a cache file corresponding to the second type of HTTP request, and caching the second type of HTTP request into the cache file. The server only has a public disk, and each SSE link can designate different parameters to represent different channels, so the scheme adopts a multilevel directory to classify messages and avoids conflict.
Further, establishing a cache file corresponding to the second type of HTTP request specifically includes: the first level directory is created based on the identity of the client sending the HTTP request of the second type, which is usually determined based on the user system identification process to ensure that the client uniquely corresponds to a specific client, and all messages belonging to this client are cached in the directory. Establishing a second-layer directory under the first-layer directory according to the sending channel type of the second-type HTTP request, and caching all messages of a channel corresponding to the client under the directory; and establishing a cache file positioned under the second-layer directory according to the millisecond-level time stamp of the second-type HTTP request. The caching of the second type of HTTP request into the cache file includes: and storing all second HTTP requests of the corresponding time stamps of the channels of the client in the cache file. Each line in the cache file represents a second-class HTTP request, one line is added for storage if a corresponding cache file exists during caching, and if the cache file does not exist, the cache file is established and cached after the cache file is established according to the mode.
As a preferred embodiment, the server circularly reads the cache information within a set time, and the specific reading step includes: traversing all cache files in a layer of directory corresponding to the identification of the client in one reading, if cache information exists in the cache files, exporting all the cache information, and emptying the cache files; and if the cache information does not exist in the cache file, deleting the cache directory without the cache information. Therefore, the cache file at a closer time point can not be deleted in each cycle of reading operation, but the cache file at a farther time point which is not used any more is only deleted, so that the performance loss caused by frequent establishment and deletion of files due to network fluctuation is avoided, and the space pressure of a server disk is saved due to timely deletion of the cache file. Wherein traversing means to visit all sub-targets under a certain target and to cycle through all sub-targets.
Referring to fig. 3, fig. 3 is a schematic flow chart illustrating a client simulating a method for implementing full-duplex instant messaging according to an embodiment of the present application.
As shown in fig. 3, the method includes steps S201 to S203.
Step S201, the client sends a first type HTTP request for requesting to establish SSE connection to the server.
Step S202, the client sends a second type of HTTP request to the server.
Step S203, after the server establishes SSE connection with the client, the client receives a second type HTTP request processing result fed back by the server through SSE connection.
As a preferred embodiment, the first type of HTTP request for requesting the establishment of the SSE connection is sent from the client to the server by encapsulating a functional object corresponding to the SSE request into a self-defined class on a program of the client, setting a function such as a send message, a message listener, an error listener, a switching channel, and the like as the class, and simulating a WebSocket specification. Furthermore, when SSE connection with a server is required, an SSE connection can be opened only by instantiating an object in the above-mentioned custom class according to a preset server address, and then a method highly similar to WebSocket specification can be called to perform operations such as information monitoring, information sending, channel switching and the like. And the client user can acquire the message sent by the server and the result feedback of the sent message by registering the callback function.
The server in the above embodiment may be a computer device, and the method for simulating full-duplex instant messaging performed on the server may be implemented in the form of a computer program, which may be run on the computer device shown in fig. 4.
As shown in fig. 4, the computer device includes a processor, a memory, and a network interface connected by a system bus, wherein the memory may include a nonvolatile storage medium and an internal memory.
The non-volatile storage medium may store an operating system and a computer program. The computer program includes program instructions that, when executed, cause the processor to perform any one of the methods for simulating full duplex instant messaging.
The processor is used for providing calculation and control capability and supporting the operation of the whole computer equipment.
The internal memory provides an environment for the execution of a computer program on a non-volatile storage medium, which when executed by the processor, causes the processor to perform any one of the methods for emulating full duplex instant messaging.
The network interface is used for network communication, such as sending assigned tasks and the like. Those skilled in the art will appreciate that the architecture shown in fig. 4 is merely a block diagram of some of the structures associated with the disclosed aspects and is not intended to limit the computing devices to which the disclosed aspects apply, as particular computing devices may include more or less components than those shown, or may combine certain components, or have a different arrangement of components.
It should be understood that the Processor may be a Central Processing Unit (CPU), and the Processor may be other general purpose processors, Digital Signal Processors (DSPs), Application Specific Integrated Circuits (ASICs), Field Programmable Gate Arrays (FPGAs) or other Programmable logic devices, discrete Gate or transistor logic devices, discrete hardware components, etc. Wherein a general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
Wherein, in one embodiment, the processor is configured to execute a computer program stored in the memory to implement the steps of:
in one embodiment, the processor, when implemented, is configured to implement:
the server receives an HTTP request sent by the client;
if the HTTP request is a first-class HTTP request, the server responds to the first-class HTTP request and establishes SSE connection with the client;
and if the HTTP request is a second type HTTP request, the server side sends a processing result of the second type HTTP request to the client side through the SSE connection.
In one embodiment, if the HTTP request is a first type HTTP request, the server responds to the first type HTTP request, and after establishing an SSE connection with the client, the processor is configured to:
the server side circularly reads the second type of HTTP requests within set time;
if the second type HTTP request is read, processing the second type HTTP request, and sending a processing result of the second type HTTP request to the client through the SSE connection;
and if the second type of HTTP request is not read, stopping circularly reading the second type of HTTP request, and closing the SSE connection.
In one embodiment, the processor is configured to, if the second type HTTP request is not read, stop reading the second type HTTP request in a loop, and close the SSE connection, implement:
the server side does not read the second type HTTP request in one reading, sends an empty information packet to the client side through the SSE connection so as to maintain the SSE connection with the client side, and subtracts a first preset time from the rest of the set time;
and after the set time is over, stopping circularly reading the second type of HTTP request, and closing the SSE connection.
In one embodiment, the processor is configured to, when processing the second type HTTP request and sending a processing result of the second type HTTP request to the client through the SSE connection if the second type HTTP request is read, implement:
the server side circularly reads the second type of HTTP requests within set time;
if the second type of HTTP request is read within the set time, resetting the set time, processing the second type of HTTP request, and sending the processing result of the second type of HTTP request to the client through the SSE connection; and the number of the first and second electrodes,
and after resetting the set time, carrying out cycle reading within the set time after resetting, and separating a second preset time between two adjacent readings within the same set time, wherein the second preset time is increased along with the increase of the reading times.
In one embodiment, the processor is configured to implement, if the HTTP request is a second type HTTP request:
the server side caches the information of the second type HTTP request to form cached information of the second type HTTP request
In one embodiment, if the HTTP request is a second-type HTTP request, the processor is configured to, when the server caches the second-type HTTP request information to form cached information, implement:
determining whether a cache file corresponding to the second type of HTTP request exists;
if a cache file corresponding to the second type of HTTP request exists, caching the second type of HTTP request in the cache file;
if the cache file corresponding to the second type HTTP request does not exist, establishing the cache file corresponding to the second type HTTP request, and caching the second type HTTP request into the cache file. The client in the above embodiment may be a computer device, and the method for simulating the duplex real-time communication in the whole country performed on the client may be implemented in the form of a computer program, which may be run on the computer device as shown in fig. 4. The specific implementation process is not described herein again as described above.
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or system that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or system. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or system that comprises the element.
The above-mentioned serial numbers of the embodiments of the present application are merely for description and do not represent the merits of the embodiments. While the invention has been described with reference to specific embodiments, the scope of the invention is not limited thereto, and those skilled in the art can easily conceive various equivalent modifications or substitutions within the technical scope of the invention. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.
Claims (10)
1. A method for realizing full-duplex instant messaging by simulation is characterized by comprising the following steps:
the server receives an HTTP request sent by the client;
if the HTTP request is a first-class HTTP request, the server responds to the first-class HTTP request and establishes SSE connection with the client;
and if the HTTP request is a second type HTTP request, the server side sends a processing result of the second type HTTP request to the client side through the SSE connection.
2. The method for simulating full-duplex instant messaging according to claim 1, wherein if the HTTP request is a first type HTTP request, the server side responding to the first type HTTP request and after establishing an SSE connection with the client side, the method comprises:
the server side circularly reads the second type of HTTP requests within set time;
if the second type HTTP request is read, processing the second type HTTP request, and sending a processing result of the second type HTTP request to the client through the SSE connection;
and if the second type of HTTP request is not read, stopping circularly reading the second type of HTTP request, and closing the SSE connection.
3. The method for simulating full-duplex instant messaging according to claim 2, wherein if the second HTTP request is not read, stopping circularly reading the second HTTP request and closing the SSE connection comprises:
the server side does not read the second type HTTP request in one reading, sends an empty information packet to the client side through the SSE connection so as to maintain the SSE connection with the client side, and subtracts a first preset time from the rest of the set time;
and after the set time is over, stopping circularly reading the second type of HTTP request, and closing the SSE connection.
4. The method for simulating and realizing full-duplex instant messaging according to claim 2, wherein if the second HTTP request is read, processing the second HTTP request, and sending a processing result of the second HTTP request to the client through the SSE connection comprises:
the server side circularly reads the second type of HTTP requests within set time;
if the second type of HTTP request is read within the set time, resetting the set time, processing the second type of HTTP request, and sending the processing result of the second type of HTTP request to the client through the SSE connection; and the number of the first and second electrodes,
and after resetting the set time, carrying out cycle reading within the set time after resetting, and separating a second preset time between two adjacent readings within the same set time, wherein the second preset time is increased along with the increase of the reading times.
5. The method for simulating full-duplex instant messaging according to claim 1, wherein if the HTTP request is a second type HTTP request, further comprising:
and the server caches the information of the second type of HTTP request to form cached information of the second type of HTTP request.
6. The method for simulating full-duplex instant messaging according to claim 5, wherein if the HTTP request is a second HTTP request, the server caches the second HTTP request information to form cached information, further comprising:
determining whether a cache file corresponding to the second type of HTTP request exists;
if a cache file corresponding to the second type of HTTP request exists, caching the second type of HTTP request in the cache file;
if the cache file corresponding to the second type HTTP request does not exist, establishing the cache file corresponding to the second type HTTP request, and caching the second type HTTP request into the cache file.
7. The method for simulating full-duplex instant messaging according to claim 6, wherein the creating of the cache file corresponding to the source according to the source of the second type HTTP request comprises:
establishing a first-layer directory according to the identification of the client;
establishing a second-layer directory under the first-layer directory according to the sending channel type of the second HTTP request;
and establishing a cache file positioned under the second-layer directory according to the timestamp of the second-type HTTP request.
8. The method for simulating full-duplex instant messaging according to claim 7, further comprising cyclically reading the buffered information for a set time, comprising:
traversing all the cache files in a layer of directory corresponding to the identification of the client in one reading;
if the cache information exists in the cache file, exporting the cache information, and emptying the cache file;
and if the cache message does not exist in the cache file, deleting the cache file.
9. A method for realizing full-duplex instant messaging by simulation is characterized by comprising the following steps:
the client sends a first type HTTP request for requesting to establish SSE connection to the server;
the client sends a second type HTTP request to the server;
after the SSE connection is established between the server and the client, the client receives a second type HTTP request processing result fed back by the server through the SSE connection.
10. A computer device comprising a processor, a memory, and a computer program stored on the memory and executable by the processor, wherein the computer program, when executed by the processor, implements the steps of implementing a full-duplex instant messaging method as claimed in any one of claims 1 to 6.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111438972.5A CN114172945B (en) | 2021-11-26 | 2021-11-26 | Method and equipment for realizing full duplex instant messaging through simulation |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111438972.5A CN114172945B (en) | 2021-11-26 | 2021-11-26 | Method and equipment for realizing full duplex instant messaging through simulation |
Publications (2)
Publication Number | Publication Date |
---|---|
CN114172945A true CN114172945A (en) | 2022-03-11 |
CN114172945B CN114172945B (en) | 2023-05-26 |
Family
ID=80481604
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202111438972.5A Active CN114172945B (en) | 2021-11-26 | 2021-11-26 | Method and equipment for realizing full duplex instant messaging through simulation |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN114172945B (en) |
Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US7849502B1 (en) * | 2006-04-29 | 2010-12-07 | Ironport Systems, Inc. | Apparatus for monitoring network traffic |
WO2017185633A1 (en) * | 2016-04-25 | 2017-11-02 | 乐视控股(北京)有限公司 | Cdn server and data caching method thereof |
CN108173946A (en) * | 2017-12-29 | 2018-06-15 | 明博教育科技股份有限公司 | A kind of method, system and correlation technique for realizing classroom real-time interactive |
CN109547511A (en) * | 2017-09-22 | 2019-03-29 | 中国移动通信集团浙江有限公司 | A kind of real-time method for pushing of WEB message, server, client and system |
US10764354B1 (en) * | 2019-03-01 | 2020-09-01 | Red Hat, Inc. | Transmitting data over a network in representational state transfer (REST) applications |
CN112769837A (en) * | 2021-01-13 | 2021-05-07 | 北京洛塔信息技术有限公司 | Websocket-based communication transmission method, device, equipment, system and storage medium |
WO2021137098A1 (en) * | 2019-12-30 | 2021-07-08 | Altice Labs, S.A. | System and method for supporting permanent http connections |
-
2021
- 2021-11-26 CN CN202111438972.5A patent/CN114172945B/en active Active
Patent Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US7849502B1 (en) * | 2006-04-29 | 2010-12-07 | Ironport Systems, Inc. | Apparatus for monitoring network traffic |
WO2017185633A1 (en) * | 2016-04-25 | 2017-11-02 | 乐视控股(北京)有限公司 | Cdn server and data caching method thereof |
CN109547511A (en) * | 2017-09-22 | 2019-03-29 | 中国移动通信集团浙江有限公司 | A kind of real-time method for pushing of WEB message, server, client and system |
CN108173946A (en) * | 2017-12-29 | 2018-06-15 | 明博教育科技股份有限公司 | A kind of method, system and correlation technique for realizing classroom real-time interactive |
US10764354B1 (en) * | 2019-03-01 | 2020-09-01 | Red Hat, Inc. | Transmitting data over a network in representational state transfer (REST) applications |
WO2021137098A1 (en) * | 2019-12-30 | 2021-07-08 | Altice Labs, S.A. | System and method for supporting permanent http connections |
CN112769837A (en) * | 2021-01-13 | 2021-05-07 | 北京洛塔信息技术有限公司 | Websocket-based communication transmission method, device, equipment, system and storage medium |
Also Published As
Publication number | Publication date |
---|---|
CN114172945B (en) | 2023-05-26 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
WO2018059222A1 (en) | File slice uploading method and apparatus, and cloud storage system | |
JP2019537768A5 (en) | ||
JP2019533235A5 (en) | ||
CN109542361B (en) | Distributed storage system file reading method, system and related device | |
KR102167613B1 (en) | Message push method and device | |
WO2023077952A1 (en) | Data processing method and system, related device, storage medium and product | |
US20130066939A1 (en) | Cloud service consuming method, cloud service packet, cloud service broker and cloud system | |
US20190028548A1 (en) | Transport of control data in proxy-based network communications | |
CN113326155B (en) | Information processing method, device, system and storage medium | |
WO2019041738A1 (en) | Client resource obtaining method and apparatus, terminal device, and storage medium | |
CN110677462B (en) | Access processing method, system, device and storage medium for multi-block chain network | |
US20200052982A1 (en) | In situ triggered function as a service within a service mesh | |
JP4205323B2 (en) | Distribution system, distribution server and distribution method, distribution program | |
CN112187903B (en) | Message pushing method and device and message service system | |
CN110535811B (en) | Remote memory management method and system, server, client and storage medium | |
CN111200606A (en) | Deep learning model task processing method, system, server and storage medium | |
WO2017032152A1 (en) | Method for writing data into storage device and storage device | |
CN113794652A (en) | Data processing method and device, electronic equipment and storage medium | |
CN113411363A (en) | Uploading method of image file, related equipment and computer storage medium | |
CN113556359A (en) | Communication protocol conversion method, device, system and gateway device | |
US20180081746A1 (en) | Application message processing system, method, and application device | |
WO2023134247A1 (en) | Container management method and container management system | |
CN114172945A (en) | Method and equipment for realizing full-duplex instant messaging by simulation | |
WO2017173844A1 (en) | Directory reading method, apparatus and system | |
CN108076111A (en) | A kind of system and method for distributing data in big data platform |
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 | ||
GR01 | Patent grant | ||
GR01 | Patent grant |