[go: up one dir, main page]

CN114172945B - Method and equipment for realizing full duplex instant messaging through simulation - Google Patents

Method and equipment for realizing full duplex instant messaging through simulation Download PDF

Info

Publication number
CN114172945B
CN114172945B CN202111438972.5A CN202111438972A CN114172945B CN 114172945 B CN114172945 B CN 114172945B CN 202111438972 A CN202111438972 A CN 202111438972A CN 114172945 B CN114172945 B CN 114172945B
Authority
CN
China
Prior art keywords
http request
type
client
server
type http
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.)
Active
Application number
CN202111438972.5A
Other languages
Chinese (zh)
Other versions
CN114172945A (en
Inventor
陈宇轩
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Wuhan Fiberhome Technical Services Co Ltd
Original Assignee
Wuhan Fiberhome Technical Services Co Ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Wuhan Fiberhome Technical Services Co Ltd filed Critical Wuhan Fiberhome Technical Services Co Ltd
Priority to CN202111438972.5A priority Critical patent/CN114172945B/en
Publication of CN114172945A publication Critical patent/CN114172945A/en
Application granted granted Critical
Publication of CN114172945B publication Critical patent/CN114172945B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/14Session management
    • H04L67/141Setup of application sessions
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L5/00Arrangements affording multiple use of the transmission path
    • H04L5/14Two-way operation using the same type of signal, i.e. duplex
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/02Protocols based on web technology, e.g. hypertext transfer protocol [HTTP]
    • YGENERAL 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
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE 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/00Reducing energy consumption in communication networks
    • Y02D30/50Reducing energy consumption in communication networks in wire-line communication networks, e.g. low power modes or reduced link rate

Landscapes

  • Engineering & Computer Science (AREA)
  • Signal Processing (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Computer And Data Communications (AREA)

Abstract

The application discloses a method and equipment 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 type HTTP request, the server responds to the first type HTTP request and establishes SSE connection with the client; if the HTTP request is a second type HTTP request, the server sends a processing result of the second type HTTP request to the client through the SSE connection, so that full duplex can be simulated to carry out instant communication under the condition that a port of the server is limited, the instantaneity of communication is improved, and the resource waste of the server is reduced.

Description

Method and equipment for realizing full duplex instant messaging through simulation
Technical Field
The present disclosure 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 simulation manner.
Background
The conventional implementation of duplex instant messaging adopts a full duplex communication WebSocket scheme, which requires a server to monitor a specific port of a device, a client initiates connection to the port, and after connection is established, the server and the client can push data to each other. However, when the server is a virtual host, the virtual host is usually a hypertext preprocessor php environment or an active server web page asp environment, and in a virtual host port limited scenario, only 80 or 443 ports are used to receive HTTP (hypertext transfer protocol Hyper Text Transfer Protocol) requests, while the service cannot be started to monitor the other ports, so WebSocket technology cannot be used in the scenario.
In the prior art, in the case that WebSocket technology cannot be used, a scheme adopted for realizing duplex-like communication is a polling or long connection technology. Polling refers to that a client side inquires whether a new message exists or not from a server side through an HTTP request, but too long polling intervals can cause the message to be untimely, too short intervals can cause excessive server load to be increased. The long connection technology is an improvement on the polling technology, the client initiates an HTTP request to the server at regular time, but the connection is kept until the long connection is continuously initiated after a message is returned, the HTTP request is always waited by the long connection mode until a data range exists, server resources are greatly wasted, and the long connection mode is not recommended in actual use. It is very necessary to provide a method capable of implementing full duplex instant messaging in an analog manner with limited virtual machine ports.
Disclosure of Invention
The main purpose of the application is to provide a method and a computer device for realizing full duplex instant messaging by simulation, which aim to solve the technical problem that a service end like a virtual host cannot perform instant full duplex communication under the condition of limited ports.
In a first aspect, the present application provides a method for implementing full duplex instant messaging in an analog manner, the method comprising the steps of:
the server receives an HTTP request sent by the client;
if the HTTP request is a first type HTTP request, the server responds to the first type HTTP request and establishes SSE connection with the client;
and if the HTTP request is a second type HTTP request, the server sends a processing result of the second type HTTP request to the client 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 HTTP request in a 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 HTTP request is not read, stopping circularly reading the second type HTTP request, and closing the SSE connection.
In some embodiments, if the second type HTTP request is not read, stopping loop reading the second type HTTP request, and closing the SSE connection, including:
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 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, including:
the server side circularly reads the second type HTTP request in a set time;
if the second type HTTP request is read in the set time, resetting the set time, 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, in addition, the processing unit,
after resetting the set time, performing cyclic reading in the set time after resetting, and spacing a second preset time between two adjacent readings in the same set time, wherein the second preset time increases with the increase of the number of readings.
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 HTTP request to form cache information of the second type 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 cache information, and further includes:
determining whether a cache file corresponding to the second type HTTP request exists;
if a cache file corresponding to the second type HTTP request exists, caching the second type HTTP request in the cache file;
if the cache file corresponding to the second type HTTP request does not exist, the cache file corresponding to the second type HTTP request is established, and the second type HTTP request is cached in the cache file.
In some embodiments, the establishing a cache file corresponding to the 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 type of the transmission channel of the second-class HTTP request;
and establishing a cache file under the second layer directory according to the timestamp of the second type HTTP request.
In some embodiments, the simulating implements a full duplex instant messaging method, further including circularly reading the cache information within a set time, including:
traversing all the cache files in a layer of catalogue corresponding to the identification of the client in one reading;
if the cache information exists in the cache file, the cache information is derived, and the cache file is emptied;
and deleting the cache file if the cache message does not exist in 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 simulated implementation of the full duplex instant messaging method as described in the first aspect.
In a third aspect, the present application further includes a method for implementing full duplex instant messaging in an analog manner, including:
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 simulated implementation of the full duplex instant messaging method as described in the third aspect.
The application provides a simulation realization full duplex instant messaging method and computer equipment, wherein an HTTP request sent by a client is received through a server; if the HTTP request is a first type HTTP request, the server responds to the first type HTTP request and establishes SSE connection with the client; if the HTTP request is a second type HTTP request, the server sends a processing result of the second type HTTP request to the client through the SSE connection, so that full duplex can be simulated to carry out instant communication under the condition that a port of the server is limited, the instantaneity of communication is improved, and the resource waste of the server is reduced.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings needed in the description of the embodiments will be briefly introduced below, and it is obvious that the drawings in the following description are some embodiments of the present application, and other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
Fig. 1 is a schematic flow chart of a server for simulating and implementing a full duplex instant messaging method according to an embodiment of the present application;
fig. 2 is a specific flowchart of a method for realizing full duplex instant messaging by a server side in a simulation manner;
fig. 3 is a schematic flow chart of a client for simulating and implementing a full duplex instant messaging method according to an embodiment of the present application;
fig. 4 is a schematic block diagram of a computer device according to an embodiment of the present application.
The realization, functional characteristics and advantages of the present application will be further described with reference to the embodiments, referring to the attached drawings.
Detailed Description
The following description of the embodiments of the present application will be made clearly and fully with reference to the accompanying drawings, in which it is evident that the embodiments described are some, but not all, of the embodiments of the present application. All other embodiments, which can be made by one of ordinary skill in the art without undue burden from the present disclosure, are within the scope of the present disclosure.
The flow diagrams depicted in the figures are merely illustrative and not necessarily all of the elements and operations/steps are included or performed in the order described. For example, some operations/steps may be further divided, combined, or partially combined, so that the order of actual execution may be changed according to actual situations.
The embodiment of the application provides a method and computer equipment for realizing full duplex instant messaging in a simulation manner.
Some embodiments of the present application are described in detail below with reference to the accompanying drawings. The following embodiments and features of the embodiments may be combined with each other without conflict.
It should be noted that HTTP herein is a hypertext transfer protocol (Hyper Text Transfer Protocol), and SSE herein is a server push Event (server-Event).
Referring to fig. 1, fig. 1 is a schematic flow chart of a server for simulating and implementing a full duplex instant messaging method according to an embodiment of the present application.
As shown in fig. 1, the method includes steps S101 to S103.
Step S101, a server receives an HTTP request sent by a client.
Illustratively, the received HTTP requests are divided 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 interaction request.
Step S102, if the HTTP request is a first type HTTP request, the server responds to the first type HTTP request and establishes SSE connection with the client.
Step 103, if the HTTP request is a second type HTTP request, the server sends a processing result of the second type HTTP request to the client through the SSE connection.
It should be noted that, after the server side and the client side form the SSE connection, the server side may actively send information to the server side 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 of limited ports, and after the received HTTP requests are processed, other ports are not needed when information is returned, and processing results can be returned to the client through SSE connection, so that the server can realize simulated full duplex under the condition of limited ports, and specific embodiments are described below.
In some embodiments, referring to fig. 2, if the request received by the server is a first type 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 type HTTP request, namely a POST request, the server caches the second type HTTP request into a cache file according to the identification and the information of the second type HTTP request to form cache information of the second type 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 the SSE connection is established, the SSE connection is maintained for a set time, the server side circularly reads the cache information formed by the cached second-type HTTP request in the set time, if the cache information is read, the cache information is processed, and the processing result of the cache information is sent to the client side through the SSE connection; if the cache information is not read in the set time, the loop reading is stopped after the set time is over.
As a preferred embodiment, referring to fig. 2, if no cache information is read within a set time, the loop reading is stopped after the set time is over, and the specific steps include: when the server side carries out cyclic reading, no cache information is read in one reading, at the moment, no HTTP request needs to be processed, 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, the first preset time is subtracted from the rest set time, the cache information is not read after the set time is over, the server side disconnects the SSE connection, resources are released, and cyclic reading is stopped at the same time.
As a preferred embodiment, referring to fig. 2, if the cache information is read, the cache information is processed, and the processing result of the cache information is sent to the client through the SSE connection, and the specific steps further include; in the cyclic reading of the server in the set time, the cache information is read, the set time is reset, and the cyclic reading is carried out in the set time after the reset. And processing the cache information, and sending the processing result of the second type HTTP request to the client through SSE connection.
And the second preset time is 0.5 seconds, namely one sleep time of the server after one reading, so as to avoid the problem of dead loop caused by overlapping of two readings, and achieve the purpose of optimizing the reading performance of the cache information.
The second preset time also increases with the number of readings in the same set time, for example, the second preset time of the interval after the first reading after the reset of the set time is 0.5 seconds, the second preset time of the interval after the second reading is 0.6 seconds, and so on. This is because the sleep time for setting the reading is short when the setting time is just reset, so as to ensure 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 existing time of the SSE connection can be prolonged, and more processing results of the HTTP request can be returned to the client through the SSE connection in the connection.
Further, in processing the cache information, sending a processing result of the second type HTTP request to the client through the SSE connection, including: the service end reads the cache information, and the service processing flow of the cache information is called when the cache information is read for one time, in the service processing flow, a user decides to perform corresponding service processing on the cache information, and when the information needs to be sent to the client, the information sending function of the service end is utilized to complete sending through SSE connection.
It should be noted that, when the server sends the processing result of the cache information to the client, the server also sends the information which occurs in real time and the remaining set time to the client, and at the same time, optionally tells the client how long to initiate a request to reconnect to establish a new SSE connection again after the SSE connection is disconnected. Therefore, the performance of the server can be optimized on the premise of ensuring the timely efficiency of the messages, if the messages are dense, the request is maintained for a long time, the timely sending of the messages is ensured, if the messages are sparse, the request is interrupted, and the resources are released to relieve the pressure of the server.
In some embodiments, the server caches the second type HTTP request in the cache file according to the identifier and the information of the second type HTTP request to form cache information of the second type HTTP request, and the specific embodiment 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 exists, directly caching the second type HTTP request in the corresponding cache file; if the corresponding cache file does not exist, a cache file corresponding to the second type HTTP request is established, and the second type HTTP request is cached in the cache file. The server has only one common disk, and different parameters can be designated in each SSE link to represent different channels, so that the scheme adopts a multi-level directory to classify the messages and avoid conflicts.
Further, establishing a cache file corresponding to the second type of HTTP request specifically includes: the first-tier directory is created based on the identity of the client sending the second-type HTTP request, which is typically determined based on the user system's identification process, to ensure that all messages attributed to that client are cached under that directory uniquely corresponding to the particular client. Establishing a second-layer directory under the first-layer directory according to the type of the transmission channel of the second-type HTTP request, and caching all messages of the corresponding channel of the client under the directory; and establishing a cache file under the second-layer directory according to the millisecond-level timestamp of the second-class HTTP request. Caching the second type of HTTP request in the cache file comprises: and storing all second-type HTTP requests of the corresponding channel corresponding time stamp of the client in the cache file. Each line in the cache file represents a second type of HTTP request, when the corresponding cache file exists in the cache, one line is added for storage, and if the cache file does not exist, the cache file is built in the mode and then cached.
As a preferred embodiment, the server side circularly reads the cache information within a set time, and the specific reading steps include: 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, deriving all the cache information, and emptying the cache files; and if the cache file does not have the cache information, deleting the cache directory without the cache information. Therefore, in the reading operation of each cycle, the cache file at a closer time point is not deleted, but only the cache file which is at a farther time point and can not be used is deleted, the performance loss caused by frequent file establishment and deletion due to network fluctuation is avoided, and the space pressure of a server disk is saved because the cache file is deleted in time. Where traversal means accessing all sub-objects subordinate to a certain object and traversing all sub-objects in a loop.
Referring to fig. 3, fig. 3 is a schematic flow chart of a client for simulating and implementing a full duplex instant messaging method according to an embodiment of the present application.
As shown in fig. 3, the method includes steps S201 to S203.
In step S201, the client sends a first type HTTP request to the server to request to establish an SSE connection.
Step S202, the client sends a second type HTTP request to the server.
Step 203, after the server establishes an SSE connection with the client, the client receives a second type HTTP request processing result fed back by the server through the SSE connection.
As a preferred embodiment, the client sends a first type of HTTP request for requesting to establish an SSE connection to the server, encapsulates a functional object corresponding to the SSE request into a custom type on a program of the client, sets functions such as a sending message, a message listener, an error listener, a switch channel, and the like as the type, and simulates WebSocket specifications to implement. When SSE connection with the server is needed, an object is instantiated by the custom class according to a preset server address, the SSE connection can be opened, and then a method highly similar to the WebSocket specification can be called to monitor information, send information, switch channels and the like. And the client user can acquire the feedback of the result of the message and the sent message issued by the server through a mode of registering a 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 as a computer program, which may be executed on the computer device as 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 non-volatile storage medium and an internal memory.
The non-volatile storage medium may store an operating system and a computer program. The computer program comprises program instructions that, when executed, cause the processor to perform any one of a number of analog implementation full duplex instant messaging methods.
The processor is used to provide computing and control capabilities to support the operation of the entire computer device.
The internal memory provides an environment for the execution of a computer program in a non-volatile storage medium that, when executed by a processor, causes the processor to perform any one of a number of analog implementations of a full duplex instant messaging method.
The network interface is used for network communication such as transmitting assigned tasks and the like. Those skilled in the art will appreciate that the structures shown in FIG. 4 are block diagrams only and do not constitute a limitation of the computer device on which the present aspects apply, and that a particular computer device may include more or less components than those shown, or may combine some of the components, or have a different arrangement of components.
It should be appreciated that the processor may be a central processing unit (Central Processing Unit, CPU), but may also be other general purpose processors, digital signal processors (Digital Signal Processor, DSP), application specific integrated circuits (Application Specific Integrated Circuit, ASIC), field-programmable gate arrays (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, or the like. Wherein the 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 run 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 type HTTP request, the server responds to the first type HTTP request and establishes SSE connection with the client;
and if the HTTP request is a second type HTTP request, the server sends a processing result of the second type HTTP request to the client through the SSE connection.
In one embodiment, the processor is configured to, 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, implement:
the server side circularly reads the second type HTTP request in a 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 HTTP request is not read, stopping circularly reading the second type HTTP request, and closing the SSE connection.
In one embodiment, the processor is configured to, if the second type of HTTP request is not read, stop loop reading the second type of HTTP request, and close the SSE connection, perform:
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 HTTP request, and closing the SSE connection.
In one embodiment, the processor is configured to, when reading the second type of HTTP request, process the second type of HTTP request, and send a processing result of the second type of HTTP request to the client through the SSE connection, perform:
the server side circularly reads the second type HTTP request in a set time;
if the second type HTTP request is read in the set time, resetting the set time, 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, in addition, the processing unit,
after resetting the set time, circularly reading in the reset set time, and spacing a second preset time between two adjacent readings in the same set time, wherein the second preset time increases with the increase of the number of readings.
In one embodiment, the processor is configured to, if the HTTP request is a second type of HTTP request, implement:
the server caches the information of the second type HTTP request to form cached information of the second type HTTP request
In one embodiment, the processor is configured to, if the HTTP request is a second type HTTP request, cache the second type HTTP request information by the server, form cache information, and when the cache information is formed, implement:
determining whether a cache file corresponding to the second type HTTP request exists;
if a cache file corresponding to the second type HTTP request exists, caching the second type HTTP request in the cache file;
if the cache file corresponding to the second type HTTP request does not exist, the cache file corresponding to the second type HTTP request is established, and the second type HTTP request is cached in the cache file. The client in the above embodiment may be a computer device, and the method of simulating national duplex instant messaging performed on the client may be implemented in the form of a computer program that can be run on the computer device as described in fig. 4. The specific implementation process is described above and will not be described here again.
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 one … …" does not exclude the presence of other like elements in a process, method, article, or system that comprises the element.
The foregoing embodiment numbers of the present application are merely for describing, and do not represent advantages or disadvantages of the embodiments. While the invention has been described with reference to certain preferred embodiments, it will be understood by those skilled in the art that various changes and substitutions of equivalents may be made and equivalents will be apparent to those skilled in the art without departing from the 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 analog implementation of full duplex instant messaging, comprising:
the server receives an HTTP request sent by the client;
if the HTTP request is a first type HTTP request, the server responds to the first type HTTP request and establishes SSE connection with the client;
if the HTTP request is a second type HTTP request, the server sends a processing result of the second type HTTP request to the client through the SSE connection;
the first type of HTTP request is a GET type HTTP request with SSE connection request establishment, and the second type of HTTP request is a POST type HTTP request with common interaction request.
2. The method for implementing full duplex instant messaging by analogy of claim 1, wherein 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 method comprises:
the server side circularly reads the second type HTTP request in a 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 HTTP request is not read, stopping circularly reading the second type HTTP request, and closing the SSE connection.
3. The method for implementing full duplex instant messaging according to claim 2, wherein if the second type of HTTP request is not read, stopping loop reading the second type of 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 HTTP request, and closing the SSE connection.
4. The method for implementing full duplex instant messaging according to claim 2, wherein if the second type of HTTP request is read, processing the second type of HTTP request, and sending a processing result of the second type of HTTP request to the client through the SSE connection, includes:
the server side circularly reads the second type HTTP request in a set time;
if the second type HTTP request is read in the set time, resetting the set time, 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, in addition, the processing unit,
after resetting the set time, circularly reading in the reset set time, and spacing a second preset time between two adjacent readings in the same set time, wherein the second preset time increases with the increase of the number of readings.
5. The method for implementing full duplex instant messaging in a simulated manner according to claim 1, wherein if said HTTP request is a second type HTTP request, further comprising:
and the server caches the information of the second type HTTP request to form cache information of the second type HTTP request.
6. The method for implementing full duplex instant messaging according to claim 5, wherein if the HTTP request is a second type HTTP request, the server caches the second type HTTP request information to form cache information, and further comprising:
determining whether a cache file corresponding to the second type HTTP request exists;
if a cache file corresponding to the second type HTTP request exists, caching the second type HTTP request in the cache file;
if the cache file corresponding to the second type HTTP request does not exist, the cache file corresponding to the second type HTTP request is established, and the second type HTTP request is cached in the cache file.
7. The method for implementing full duplex instant messaging in a simulated manner according to claim 6, wherein establishing a cache file corresponding to a 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 type of the transmission channel of the second-class HTTP request;
and establishing a cache file under the second layer directory according to the timestamp of the second type HTTP request.
8. The analog-implemented full duplex instant messaging method of claim 7, further comprising cyclically reading the buffered information for a set time comprising:
traversing all the cache files in a layer of catalogue corresponding to the identification of the client in one reading;
if the cache information exists in the cache file, the cache information is derived, and the cache file is emptied;
and deleting the cache file if the cache information does not exist in the cache file.
9. A method for analog implementation of full duplex instant messaging, 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.
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 according to any of claims 1 to 6.
CN202111438972.5A 2021-11-26 2021-11-26 Method and equipment for realizing full duplex instant messaging through simulation Active CN114172945B (en)

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 CN114172945A (en) 2022-03-11
CN114172945B true 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)

* Cited by examiner, † Cited by third party
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

Patent Citations (7)

* Cited by examiner, † Cited by third party
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
CN114172945A (en) 2022-03-11

Similar Documents

Publication Publication Date Title
CN109684358B (en) Data query method and device
CN113641457B (en) Container creation method, device, apparatus, medium, and program product
US8544075B2 (en) Extending a customer relationship management eventing framework to a cloud computing environment in a secure manner
US10951395B2 (en) Data fetching in data exchange networks
US11025724B2 (en) Transport of control data in proxy-based network communications
CN108718347B (en) Domain name resolution method, system, device and storage medium
JP2019533235A5 (en)
CN107861686A (en) File memory method, service end and computer-readable recording medium
JP4205323B2 (en) Distribution system, distribution server and distribution method, distribution program
CN111193789B (en) Subscription information push method, device, computer equipment and readable storage medium
CN112104679B (en) Method, device, equipment and medium for processing hypertext transfer protocol request
CN110535811A (en) Remote memory management method and system, server, client, storage medium
WO2017032152A1 (en) Method for writing data into storage device and storage device
KR20210044281A (en) Method and apparatus for ensuring continuous device operation stability in cloud degraded mode
CN102572804B (en) Data calling method and device
US9893972B1 (en) Managing I/O requests
CN114285889A (en) Method, device and equipment for processing configuration information of application service
CN114172945B (en) Method and equipment for realizing full duplex instant messaging through simulation
CN111245949A (en) File filing and transmission method, device and equipment
US11663058B1 (en) Preemptive filtering of events of an event bus with a deterministic filter
JP6193078B2 (en) Message transfer system and queue management method
CN108471375B (en) Message processing method, device and terminal
CN116389252B (en) Method, device, system, electronic equipment and storage medium for updating container network
CN111488324A (en) Distributed network file system based on message middleware and working method thereof
CN103401688A (en) Message-oriented middleware transmission integration system based on Eucalyptus cloud 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