Communication method and device, equipment, storage medium and program product
By combining the HTTP/HTTPS protocol to process service content and the MQTT/XMPP/WebSocket protocol for real-time messaging, the problem of low efficiency of a single protocol in instant messaging software is solved, and efficient instant messaging functions are achieved.
Patent Information
- Application Number
- CN202411171431.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-23
- Publication Date
- 2024-12-03
AI Technical Summary
Existing instant messaging software is less efficient when using a single communication protocol, and their respective protocols are insufficient, resulting in inefficiency in communication.
Using a combination of multiple communication protocols, the server handles complex business content through HTTP or HTTPS protocols, such as obtaining authentication identifiers, friend list operations, etc., and using MQTT, XMPP or WebSocket protocols for real-time messaging and friend status push, combining two The advantages of class protocols realize instant messaging functions.
It improves the efficiency of instant messaging software, uses the advantages of each protocol, solves the problem of insufficient single protocol, and realizes efficient communication in friend relationship scenarios.
Smart Images

Figure CN119071365A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of communication technology, and in particular to a communication method, device, equipment, storage medium and program product. Background Art
[0002] Message Queuing Telemetry Transport (MQTT) is a lightweight communication protocol used in low-bandwidth and unstable network environments in the Internet of Things (IoT). Hypertext Transfer Protocol (HTTP) / Hypertext Transfer Protocol Secure (HTTPS) is the most widely used communication protocol on the Internet for web browsing and data transmission. Current instant messaging (IM) software usually uses a single communication protocol (MQTT or HTTP) to implement all functions.
[0003] However, when a single communication protocol is used to implement all functions, each single communication protocol has its own shortcomings, resulting in low efficiency of instant messaging software. Thus, the communication efficiency is low. Summary of the invention
[0004] The present application provides a communication method, apparatus, device, storage medium and program product, which are used to solve the technical problem that when a single communication protocol is used to implement all functions, each single communication protocol has its own shortcomings, resulting in low efficiency of instant messaging software.
[0005] In order to achieve the above objectives, this application adopts the following technical solutions:
[0006] In a first aspect, a communication method is provided, which is applied to a first client, and the method includes: sending a request for obtaining a communication object to a first server, and receiving a request result corresponding to the request sent by the first server; the first client communicates with the first server via a first communication protocol; receiving status information of the communication object sent by a second server; and the first client communicates with the second server via a second communication protocol.
[0007] In one possible implementation, before sending a request to the first server for obtaining a communication object, the method also includes: sending a verification request to the first server; the verification request includes verification information; the verification request is used to instruct the first server to verify the first client; receiving an authentication identifier sent by the first server; the authentication identifier is sent when the first server successfully verifies the verification information.
[0008] In a possible implementation, before receiving the status information of the communication object sent by the second server, the method also includes: sending a login request to the second server; the login request includes an authentication identifier; and establishing a communication connection with the second server when the second server successfully verifies the authentication identifier.
[0009] In a possible implementation, the request includes an authentication identifier; the authentication identifier is used to instruct the first server to determine whether a request result corresponding to the request is a communication object.
[0010] In a possible implementation, the communication object includes a friend list and / or required files.
[0011] In a possible implementation, when the communication object includes a friend list, before sending a request for obtaining the communication object to the first server, the method also includes: receiving a friend list update message sent by the second server; the friend list update message is a message sent by the first server and received by the second server; the friend list update message is a message generated by the first server when receiving an operation request sent by the second client; the operation request is used to instruct the first server to perform a target operation on the friend list; the second client is a client to which the friends in the friend list belong.
[0012] In a possible implementation manner, the target operation includes at least one of the following: deleting a friend in the friend list, and adding a friend to the friend list.
[0013] In a possible implementation, the first communication protocol is the Hypertext Transfer Protocol HTTP or the Hypertext Transfer Security Protocol HTTPS, and the second communication protocol is any one of the following: Message Queue Telemetry Transport MQTT, Extensible Messaging and Presentation Protocol XMPP, or Network Sockets Protocol.
[0014] In one possible implementation, when the communication object includes a friend list, after receiving the status information of the communication object sent by the second server, the method also includes: sending a chat message to the second server; the chat message is a message sent by the first client to the second client; the second client is the client to which the friend in the friend list belongs; the chat message is used to instruct the second server to determine whether to send the chat message to the second client based on the online status of the second client.
[0015] In a possible implementation, the second server is used to send a chat message to the second client when the online status of the second client is online.
[0016] In a possible implementation, the second server is used to store the chat message when the online status of the second client is offline, and to send the chat message to the second client when the online status of the second client is online.
[0017] In a second aspect, a communication device is provided, which includes: a transmission unit; a transmission unit for sending a request for obtaining a communication object to a first server, and receiving a request result corresponding to the request sent by the first server; a first client and the first server communicate via a first communication protocol; the transmission unit is also used to receive status information of the communication object sent by a second server; the first client and the second server communicate via a second communication protocol.
[0018] In a possible implementation, the transmission unit is also used to send a verification request to the first server; the verification request includes verification information; the verification request is used to instruct the first server to verify the first client; the transmission unit is also used to receive an authentication identifier sent by the first server; the authentication identifier is sent when the first server successfully verifies the verification information.
[0019] In one possible implementation, the communication device also includes: a processing unit; a transmission unit, further used to send a login request to the second server; the login request includes an authentication identifier; and a processing unit, used to establish a communication connection with the second server when the second server successfully verifies the authentication identifier.
[0020] In a possible implementation, the request includes an authentication identifier; the authentication identifier is used to instruct the first server to determine whether a request result corresponding to the request is a communication object.
[0021] In a possible implementation, the communication object includes a friend list and / or required files.
[0022] In a possible implementation, the transmission unit is also used to receive a friend list update message sent by a second server; the friend list update message is a message sent by the first server and received by the second server; the friend list update message is a message generated by the first server when receiving an operation request sent by a second client; the operation request is used to instruct the first server to perform a target operation on the friend list; the second client is a client to which the friend in the friend list belongs.
[0023] In a possible implementation manner, the target operation includes at least one of the following: deleting a friend in the friend list, and adding a friend to the friend list.
[0024] In a possible implementation, the first communication protocol is the Hypertext Transfer Protocol HTTP or the Hypertext Transfer Security Protocol HTTPS, and the second communication protocol is any one of the following: Message Queue Telemetry Transport MQTT, Extensible Messaging and Presentation Protocol XMPP, or Network Sockets Protocol.
[0025] In a possible implementation, the transmission unit is also used to send a chat message to the second server; the chat message is a message sent by the first client to the second client; the second client is the client to which the friend in the friend list belongs; the chat message is used to instruct the second server to determine whether to send the chat message to the second client based on the online status of the second client.
[0026] In a possible implementation, the second server is used to send a chat message to the second client when the online status of the second client is online.
[0027] In a possible implementation, the second server is used to store the chat message when the online status of the second client is offline, and to send the chat message to the second client when the online status of the second client is online.
[0028] In a third aspect, an electronic device comprises: a processor and a memory; wherein the memory is used to store one or more programs, and the one or more programs include computer execution instructions. When the electronic device is running, the processor executes the computer execution instructions stored in the memory to enable the electronic device to perform a communication method as in the first aspect.
[0029] In a fourth aspect, a computer-readable storage medium storing one or more programs is provided. The one or more programs include instructions. When the instructions are executed by a computer, the computer executes a communication method as described in the first aspect.
[0030] In a fifth aspect, a computer program product is provided. When the computer instructions are executed on an electronic device, the electronic device executes a communication method as in the first aspect.
[0031] The present application provides a communication method, apparatus, device, storage medium and program product, which are applied to communication scenarios. When a client needs to communicate, a request for obtaining a communication object is sent to a first server based on a first communication protocol, and a request result corresponding to the request sent by the first server based on the first communication protocol is received. And, the status information of the communication object sent by the second server is received based on a second communication protocol. That is, under normal circumstances, during communication, different communication protocols have advantages in different functions. Therefore, by implementing the function by a communication protocol that has an advantage in the function of obtaining a communication object, and by implementing the function by a communication protocol that has an advantage in obtaining the status information of a communication object, the efficiency of communication can be improved.
[0032] Through the above method, the function can be realized by a communication protocol that has an advantage in acquiring the function of the communication object, and the function can be realized by a communication protocol that has an advantage in acquiring the status information of the communication object. Thus, the technical problem that when a single communication protocol is used to realize all functions, each single communication protocol has its own shortcomings, resulting in low efficiency of instant messaging software is solved, and the efficiency of communication is improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] Figure 1 A schematic diagram of the structure of a communication system provided in an embodiment of the present application;
[0034] Figure 2 A communication method according to an embodiment of the present invention is provided. Figure 1 ;
[0035] Figure 3 A schematic diagram of a process of obtaining a friend list and pushing online status provided in an embodiment of the present application;
[0036] Figure 4 A schematic diagram of a process of pushing a friend's online status provided in an embodiment of the present application;
[0037] Figure 5 A communication method according to an embodiment of the present invention is provided. Figure 2 ;
[0038] Figure 6 A schematic diagram of a system login process provided in an embodiment of the present application;
[0039] Figure 7 A communication method according to an embodiment of the present invention is provided. Figure 3 ;
[0040] Figure 8 A communication method according to an embodiment of the present invention is provided. Figure 4 ;
[0041] Fig. 9 A schematic diagram of a process flow of event push processing provided in an embodiment of the present application;
[0042] Fig.10 A communication method according to an embodiment of the present invention is provided. Figure 5 ;
[0043] Fig.11 A schematic diagram of a real-time message push process provided in an embodiment of the present application;
[0044] Fig.12 A schematic diagram of an offline message push process provided in an embodiment of the present application;
[0045] Fig.13 A schematic diagram of the structure of a communication device provided in an embodiment of the present application;
[0046] Fig.14 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0047] The technical solutions in the embodiments of the present application will be described below in conjunction with the drawings in the embodiments of the present application.
[0048] In the description of this application, unless otherwise specified, " / " means "or", for example, A / B can mean A or B. "And / or" in this article is merely a description of the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. In addition, "at least one" and "plurality" refer to two or more. The words "first", "second", etc. do not limit the quantity and execution order, and the words "first", "second", etc. do not limit them to be different.
[0049] IM can use one of a variety of communication protocols (such as Extensible Messaging and Presence Protocol (XMPP), HTTP, MQTT, WebSocket) to implement all functions. XMPP is an open standard communication protocol based on Extensible Markup Language (XML) for the transmission of instant messages and online status (presence). The XML structure of XMPP is relatively redundant, resulting in the transmission efficiency not being the highest. In addition, the distributed architecture of XMPP may make the server-side implementation more complicated. XMPP has advantages in maintaining long connections and real-time sending and receiving messages (such as sending and receiving chat messages, pushing notifications of friends' online status, friend deletion, friend addition, etc.), but has limited functions in processing business content (such as obtaining authentication tokens, obtaining friend lists and operating friend lists, file upload and download, and other business logic).
[0050] MQTT is a lightweight messaging protocol used in low-bandwidth and unstable network environments in the Internet of Things. MQTT is mainly used in IoT devices and may not be flexible enough for instant messaging software that requires a lot of business logic and user interaction. MQTT has advantages in maintaining long connections and sending and receiving messages in real time, but has limited functions in processing business content.
[0051] WebSocket provides a protocol for full-duplex communication over a single Transmission Control Protocol (TCP) connection. WebSocket requires custom message and event processing, which makes service implementation more complex and has no native mechanism to support reliable message transmission. WebSocket has advantages in maintaining long connections and sending and receiving messages in real time, but has limited functionality in processing service content.
[0052] HTTP and HTTPS are the most widely used protocols on the Internet, used for web browsing and data transmission. HTTP and HTTPS protocols are less efficient in maintaining long connections and sending and receiving messages in real time, and are not suitable for frequent data exchange, but they have advantages in processing business content.
[0053] In summary, the above two types of communication protocols each have their own shortcomings. When a single type of communication protocol is used to implement all functions, the efficiency of the instant messaging software will be low.
[0054] To solve the above problems, an instant messaging method combining two types of communication protocols is needed to improve the efficiency of instant messaging. The present application provides a communication method that interacts with a corresponding server through a first communication protocol (i.e., HTTP or HTTPS) to handle complex business content (including obtaining authentication identification, obtaining a friend list, and operating a friend list, uploading and downloading files, etc.). Through a second communication protocol (i.e., MQTT, XMPP or WebSocket), messages are sent and received in real time (including sending and receiving chat messages, pushing notifications such as friend online status, friend deletion, and friend addition), thereby utilizing the advantages of the first communication protocol and the second communication protocol to realize instant messaging functions in scenarios involving friend relationships.
[0055] A communication method provided in an embodiment of the present application can be applicable to a communication system. Figure 1 FIG. 1 shows a schematic diagram of the structure of a communication system. Figure 1 As shown, the communication system 10 includes: a first client 11, a first server 12, a second server 13, a database 14, and a second client 15. The first client 11, the first server 12, the second server 13, the database 14, and the second client 15 can be connected in a wired manner or in a wireless manner, which is not limited in the embodiment of the present invention.
[0056] The first client 11 and the second client 15 are used as business terminals to communicate with the first server through the first communication protocol to process business content, and to establish a long connection with the second server through the second communication protocol to realize the sending and receiving of real-time messages. The first server 12 is used to receive requests for processing business content based on the first communication protocol and process the business content. The second server 13 is used as a transit server for instant messages, and is used to maintain a long connection with the first client 11 and the second client 15 based on the second communication protocol to complete the sending and receiving of messages. The database 14 is used to store business data (such as a friend list, a friend's online status, etc.), and cache chat messages when the friend of the first client 11 (i.e., the second client 15) is offline.
[0057] Optionally, the first client 11 and the second client 15 may be terminal devices such as personal computers, smart phones, tablet computers, etc. The first server 12 and the second server 13 may be servers, or a server group consisting of multiple servers. The database 14 may be a hardware or software device for storing and managing data, such as a relational database, an object-oriented database, a hierarchical database, etc.
[0058] The first server 12 may be an HTTP server (also referred to as HTTP Server) or an HTTPS server (also referred to as HTTPS Server). The second server 13 may be an MQTT server (also referred to as MQTT Broker), an XMPP server (also referred to as XMPP Broker) or a WebSocket server (also referred to as WebSocket Broker).
[0059] A communication method provided by an embodiment of the present application is described below in conjunction with the accompanying drawings. Figure 2 As shown, a communication method provided in an embodiment of the present application is applied to a first client, and the method includes S201-S202:
[0060] S201: Send a request for obtaining a communication object to a first server, and receive a request result corresponding to the request sent by the first server.
[0061] The first client communicates with the first server via a first communication protocol.
[0062] It can be understood that the first client can send a request for obtaining a communication object to the first server based on the first communication protocol, and receive a request result corresponding to the request sent by the first server based on the first communication protocol.
[0063] Optionally, the first client may be a terminal device such as a user's personal computer, a smart phone, or a tablet computer. The first server may be a server corresponding to the first communication protocol. The first communication protocol may be a communication protocol such as HTTP or HTTPS that has advantages in processing business content (such as obtaining an authentication identifier, obtaining a friend list, operating a friend list, uploading and downloading files, and other business logic).
[0064] When the first client needs to communicate, the first client can send a request for obtaining a communication object to the first server based on the first communication protocol. Further, after receiving the request, the first server can query a database or other device. If the first server obtains the communication object, the first server can return the communication object to the first client as a request result corresponding to the request based on the first communication protocol. Further, the first client can receive the communication object sent by the first server based on the first communication protocol.
[0065] If the first server fails to obtain the communication object, the first server may return a message indicating that the communication object has not been obtained to the first client as a request result corresponding to the request based on the first communication protocol. Further, the first client may receive a message indicating that the communication object has not been obtained sent by the first server based on the first communication protocol.
[0066] In a possible implementation, the communication object includes a friend list and / or required files.
[0067] Optionally, the friend list may be a friend list of the first client. The required file may be a file that the first client needs to upload or download. The file may be a document, an installation package, or other file.
[0068] Exemplarily, the friend list may include: friend A, friend B, friend C, and friend D.
[0069] In a possible implementation, the request includes an authentication identifier; the authentication identifier is used to instruct the first server to determine whether a request result corresponding to the request is a communication object.
[0070] It should be noted that, according to the communication principle of the first communication protocol, the connection established between the client and the corresponding server based on the first communication protocol is a short connection, that is, each time before processing the client's request based on the first communication protocol, the client needs to establish a connection with the corresponding server. And, in order to ensure the security of communication, before the client establishes a connection with the corresponding server, it is necessary to verify the authentication identifier carried in the request, and when the authentication identifier is verified, the connection between the client and the corresponding server is established.
[0071] Optionally, after receiving the request for obtaining the communication object, the first server can verify the authentication identifier in the request to determine whether the authentication identifier is a legal identifier. If the authentication identifier is a legal identifier, it is determined that the authentication identifier authentication is successful, and the first server can further query a database or other device to obtain the communication object. If the authentication identifier is an illegal identifier, it is determined that the authentication identifier authentication is unsuccessful, and the first server can return the authentication failure information to the first client.
[0072] The present application can ensure the security of establishing a communication connection by verifying the authentication identifier of the request when processing the corresponding request based on the first communication protocol.
[0073] S202: Receive status information of the communication object sent by the second server.
[0074] The first client and the second server communicate with each other via a second communication protocol.
[0075] It can be understood that the first client can receive the status information of the communication object sent by the second server.
[0076] Optionally, the second server may be a server corresponding to the second communication protocol. The second communication protocol may be a communication protocol such as MQTT, XMPP or WebSocket that has advantages in maintaining a long connection and sending and receiving messages in real time (eg, sending and receiving chat messages, pushing friends' online status).
[0077] After the first client establishes a connection with the second server, the second server can obtain the communication object by querying the database, and then obtain the status information of the communication object, and return the status information of the communication object to the first client based on the second communication protocol. Further, the first client can receive the status information of the communication object sent by the second server based on the second communication protocol. The status information of the communication object can be the online status of the friends in the friend list, and the online status can include: online, offline, etc.
[0078] It should be noted that each client needs to establish a connection with the second server when going online, so the second server can know the online status of each client.
[0079] In a possible implementation manner, specific information on how to establish a connection between the first client and the second server may refer to the embodiments described below.
[0080] For example, Figure 3 As shown, when the communication object is a friend list, the first client sends a request to the first server to obtain the friend list, and then the first server obtains the friend list by querying the database, and returns the friend list to the first client. The second server obtains the friend list by querying the database, and then obtains the online status of the friends in the friend list, and sends the online status of the friends to the first client, and pushes the message that the first client is online to the client to which the online friends belong. Furthermore, after receiving the online status of the friend, the first client returns a confirmation message (Acknowledge character, ACK) of receiving the online status of the friend to the second server.
[0081] Optionally, Figure 4 As shown, a schematic diagram of a process of pushing the online status of a friend is shown. Assuming that the online status of friend A among the online status of friends received by the first client is offline, if after a period of time, the second client to which friend A belongs sends a login request to the second server, the second server returns a confirmation message of receiving the login request to the second client after receiving the login request. At the same time, the second server can obtain the friend list of the second client by querying the database, and push the message of the second client going online to the first client in the friend list. After receiving the message of the second client going online, the first client can modify the online status of the user of the second client to online, and return a confirmation message of receiving the message of the second client going online to the second server.
[0082] In one design, Figure 5 As shown, a communication method provided in an embodiment of the present application, before the above step S201, the method further includes S301-S302:
[0083] S301. Send a verification request to a first server.
[0084] The verification request includes verification information; the verification request is used to instruct the first server to verify the first client.
[0085] S302: Receive an authentication identifier sent by the first server.
[0086] The authentication identifier is sent when the first server successfully authenticates the authentication information.
[0087] Optionally, the verification information may include a user name and password of the first client. Figure 6 As shown, the first client can send a verification request to the first server. Further, the first server can verify the verification information included in the verification request by querying a database. The first server can query the database based on the user name and password to see whether the user name and password exist. If the user name and password exist, the first client is verified successfully. If the user name and password do not exist, the first client is not verified successfully.
[0088] When the first server determines that the first client has passed the authentication, the first server obtains the authentication identifier of the first client by querying the database, and sends the authentication identifier to the first client.
[0089] The present application can obtain the authentication identifier based on the first communication protocol, which has specific advantages in obtaining the authentication identifier, thereby improving communication efficiency, and facilitating the subsequent establishment of a secure connection based on the authentication identifier, thereby ensuring the security of communication.
[0090] In one design, Figure 7 As shown, a communication method provided in an embodiment of the present application, before the above step S202, the method further includes S401-S402:
[0091] S401. Send a login request to a second server.
[0092] The login request includes an authentication identifier.
[0093] S402: When the second server successfully verifies the authentication identifier, establish a communication connection with the second server.
[0094] Alternatively, if Figure 6As shown, the first client can send a login request including an authentication identifier to the second server. After receiving the login request, the second server can verify the authentication identifier and determine whether the authentication identifier is a legal identifier. If the authentication identifier is a legal identifier, it is determined that the authentication identifier is authenticated, a communication connection is established between the first client and the second server, and a message indicating that the authentication identifier is authenticated is returned. If the authentication identifier is an illegal identifier, it is determined that the authentication identifier is not authenticated, and a message indicating that the authentication identifier is not authenticated is returned.
[0095] This application can establish a long connection between the client and the corresponding server based on the second communication protocol that has an advantage in maintaining a long connection, thereby improving the efficiency of instant messaging. A secure long connection can be established by verifying the authentication identifier, thereby ensuring the security of communication.
[0096] In one design, Figure 8 As shown, in a communication method provided by an embodiment of the present application, when the communication object includes a friend list, before the above step S201, the method further includes S501:
[0097] S501: Receive a friend list update message sent by a second server.
[0098] Among them, the friend list update message is a message sent by the first server and received by the second server; the friend list update message is a message generated by the first server when it receives an operation request sent by the second client; the operation request is used to instruct the first server to perform a target operation on the friend list; the second client is the client to which the friend in the friend list belongs.
[0099] Alternatively, if Fig. 9 As shown, if the second client to which the friend of the first client belongs sends an operation request to the first server, the first server can query the friend list stored in the database, perform the target operation on the friend list, and return the execution result of the target operation to the second client. The execution result of the target operation can be execution success or execution failure.
[0100] If the target operation is successfully executed, the first server can call the interface to send a friend list update message to the second server. Further, the second server can forward the friend list update message to the first client. Further, the first client sends a request to the first server for obtaining a friend list, and receives the friend list returned by the first server. The first client can update the original friend list according to the returned friend list, and return a confirmation message of updating the friend list to the second server.
[0101] In a possible implementation manner, the target operation includes at least one of the following: deleting a friend in the friend list, and adding a friend to the friend list.
[0102] The present application can perform deletion or addition operations on a friend list based on a first communication protocol that has an advantage in performing deletion or addition operations on a friend list, and can push notifications of friend deletion, friend addition, etc. to a client based on a second communication protocol that has an advantage in pushing notifications of friend deletion, friend addition, etc., thereby combining the advantages of these two types of communication protocols to improve the efficiency of instant messaging.
[0103] In one design, Fig.10 As shown, a communication method provided in an embodiment of the present application, after the above step S202, the method further includes S601:
[0104] S601. Send a chat message to a second server.
[0105] Among them, the chat message is a message sent by the first client to the second client; the second client is the client to which the friend in the friend list belongs; the chat message is used to instruct the second server to determine whether to send the chat message to the second client based on the online status of the second client.
[0106] Optionally, the chat message may be a group chat message such as a picture, video, text, etc. and / or a private chat message. Fig.11 and Fig.12 As shown, when the first client needs to send a chat message to the second client, the first client can send the chat message to the second server based on the second communication protocol. The second server can receive the chat message and return a confirmation message of receiving the chat message to the first client. Further, the second server can determine whether to send the chat message to the second client based on the online status of the second client.
[0107] The present application can send and receive chat messages based on a second communication protocol that has advantages in sending and receiving chat messages, thereby improving the efficiency of instant messaging.
[0108] In a possible implementation, the second server is used to send a chat message to the second client when the online status of the second client is online.
[0109] Alternatively, if Fig.11 As shown, the second server can write the chat message into the database and forward the chat message to the second client when the online status of the second client is online. Further, after receiving the chat message, the second client returns a confirmation message of receiving the chat message to the second server. After receiving the confirmation message returned by the second server, the second server deletes the chat message in the database.
[0110] The present application can send and receive real-time chat messages based on the second communication protocol which has advantages in sending and receiving chat messages, thereby improving the efficiency of instant messaging.
[0111] In a possible implementation, the second server is used to store the chat message when the online status of the second client is offline, and to send the chat message to the second client when the online status of the second client is online.
[0112] Alternatively, if Fig.12 As shown, the second server can write the chat message into the database when the online status of the second client is offline, and after receiving the login request sent by the second client, return a confirmation message of receiving the login request to the second client. Further, the second server can read the chat message from the database and forward the chat message to the second client. Further, after receiving the chat message, the second client returns a confirmation message of receiving the chat message to the second server. After receiving the confirmation message returned by the second server, the second server deletes the chat message in the database.
[0113] The present application can send and receive offline chat messages based on the second communication protocol which has advantages in sending and receiving chat messages, thereby improving the efficiency of instant messaging, avoiding the problem that users cannot receive offline messages after going offline, and improving the user experience.
[0114] The above mainly introduces the solution provided by the embodiment of the present application from the perspective of the method. In order to realize the above functions, it includes hardware structures and / or software modules corresponding to the execution of each function. Those skilled in the art should easily realize that, in combination with the units and algorithm steps of each example described in the embodiment disclosed herein, the embodiment of the present application can be implemented in the form of hardware or a combination of hardware and computer software. Whether a function is executed in the form of hardware or computer software driving hardware depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of the present application.
[0115] The embodiment of the present application can divide the functional modules of a communication method according to the above method example. For example, each functional module can be divided corresponding to each function, or two or more functions can be integrated into one processing module. The above integrated module can be implemented in the form of hardware or in the form of software functional modules. Optionally, the division of modules in the embodiment of the present application is schematic and is only a logical function division. There may be other division methods in actual implementation.
[0116] Fig.13A schematic diagram of the structure of a communication device provided in an embodiment of the present application. Fig.13 As shown, a communication device 90 is used to improve the efficiency of communication, for example, to perform Figure 2 A communication method is shown. The communication device 90 includes: a transmission unit 901.
[0117] Transmission unit 901 is used to send a request for obtaining a communication object to the first server, and receive a request result corresponding to the request sent by the first server; the first client communicates with the first server through a first communication protocol; the transmission unit 901 is also used to receive status information of the communication object sent by the second server; the first client communicates with the second server through a second communication protocol.
[0118] In a possible implementation, the transmission unit 901 is also used to send a verification request to the first server; the verification request includes verification information; the verification request is used to instruct the first server to verify the first client; the transmission unit 901 is also used to receive an authentication identifier sent by the first server; the authentication identifier is sent when the first server successfully verifies the verification information.
[0119] In one possible implementation, the communication device 90 also includes: a processing unit 902; a transmission unit 901, which is also used to send a login request to the second server; the login request includes an authentication identifier; and the processing unit 902, which is used to establish a communication connection with the second server when the second server successfully verifies the authentication identifier.
[0120] In a possible implementation, the request includes an authentication identifier; the authentication identifier is used to instruct the first server to determine whether a request result corresponding to the request is a communication object.
[0121] In a possible implementation, the communication object includes a friend list and / or required files.
[0122] In a possible implementation, the transmission unit 901 is also used to receive a friend list update message sent by a second server; the friend list update message is a message sent by the first server and received by the second server; the friend list update message is a message generated by the first server when receiving an operation request sent by a second client; the operation request is used to instruct the first server to perform a target operation on the friend list; the second client is a client to which the friend in the friend list belongs.
[0123] In a possible implementation manner, the target operation includes at least one of the following: deleting a friend in the friend list, and adding a friend to the friend list.
[0124] In a possible implementation, the first communication protocol is the Hypertext Transfer Protocol HTTP or the Hypertext Transfer Security Protocol HTTPS, and the second communication protocol is any one of the following: Message Queue Telemetry Transport MQTT, Extensible Messaging and Presentation Protocol XMPP, or Network Sockets Protocol.
[0125] In a possible implementation, the transmission unit 901 is also used to send a chat message to the second server; the chat message is a message sent by the first client to the second client; the second client is the client to which the friend in the friend list belongs; the chat message is used to instruct the second server to determine whether to send the chat message to the second client based on the online status of the second client.
[0126] In a possible implementation, the second server is used to send a chat message to the second client when the online status of the second client is online.
[0127] In a possible implementation, the second server is used to store the chat message when the online status of the second client is offline, and to send the chat message to the second client when the online status of the second client is online.
[0128] In the case of implementing the functions of the above-mentioned integrated modules in the form of hardware, the present application embodiment provides a possible structural diagram of the electronic device involved in the above-mentioned embodiment. Fig.14 As shown, an electronic device 100 is used to improve the efficiency of communication, for example, to perform Figure 2 The electronic device 100 includes a processor 1001, a memory 1002 and a bus 1003. The processor 1001 and the memory 1002 can be connected via the bus 1003.
[0129] The processor 1001 is the control center of the communication device, which can be a processor or a general term for multiple processing elements. For example, the processor 1001 can be a general-purpose central processing unit (CPU) or other general-purpose processors. Among them, the general-purpose processor can be a microprocessor or any conventional processor.
[0130] As an embodiment, the processor 1001 may include one or more CPUs, such as Fig.14 CPU 0 and CPU 1 are shown in .
[0131] The memory 1002 may be a read-only memory (ROM) or other type of static storage device that can store static information and instructions, a random access memory (RAM) or other type of dynamic storage device that can store information and instructions, an electrically erasable programmable read-only memory (EEPROM), a disk storage medium or other magnetic storage device, or any other medium that can be used to carry or store desired program code in the form of instructions or data structures and can be accessed by a computer, but is not limited to these.
[0132] As a possible implementation, the memory 1002 may exist independently of the processor 1001, and the memory 1002 may be connected to the processor 1001 via the bus 1003 to store instructions or program codes. When the processor 1001 calls and executes the instructions or program codes stored in the memory 1002, a communication method provided in an embodiment of the present application can be implemented.
[0133] In another possible implementation, the memory 1002 may also be integrated with the processor 1001 .
[0134] The bus 1003 may be an industry standard architecture (ISA) bus, a peripheral component interconnect (PCI) bus, or an extended industry standard architecture (EISA) bus. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Fig.14 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0135] It should be pointed out that Fig.14 The structure shown does not constitute a limitation on the electronic device 100. Fig.14 In addition to the components shown, the electronic device 100 may include more or fewer components than shown, or combine certain components, or arrange the components differently.
[0136] As an example, combining Fig.13 The functions implemented by the transmission unit 901 and the processing unit 902 in the communication device 90 are similar to those Fig.14 The function of processor 1001 in is the same.
[0137] Optional, such as Fig.14 As shown, the electronic device 100 provided in the embodiment of the present application may further include a communication interface 1004 .
[0138] The communication interface 1004 is used to connect with other devices through a communication network. The communication network may be Ethernet, wireless access network, wireless local area network (WLAN), etc. The communication interface 1004 may include a receiving unit for receiving data and a sending unit for sending data.
[0139] In one design, in the electronic device provided in the embodiment of the present application, the communication interface can also be integrated into the processor.
[0140] Through the description of the above implementation methods, those skilled in the art can clearly understand that for the convenience and simplicity of description, only the division of the above functional units is used as an example. In practical applications, the above functions can be assigned to different functional units as needed, that is, the internal structure of the device can be divided into different functional units to complete all or part of the functions described above. The specific working process of the system, device and unit described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here.
[0141] An embodiment of the present application also provides a computer-readable storage medium, in which instructions are stored. When a computer executes the instructions, the computer executes each step in the method flow shown in the above method embodiment.
[0142] An embodiment of the present application provides a computer program product. When a computer instruction is executed on an electronic device, the electronic device executes a communication method in the above method embodiment.
[0143] Among them, the computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media (a non-exhaustive list) include: an electrical connection with one or more wires, a portable computer disk, a hard disk. Random access memory (random access memory, RAM), read-only memory (read-only memory, ROM), erasable programmable read only memory (erasable programmable read only memory, EPROM), registers, hard disks, optical fibers, portable compact disc read-only memory (compact disc read-only memory, CD-ROM), optical storage devices, magnetic storage devices, or the above in a suitable combination, or any other form of computer-readable storage medium known in the art.
[0144] An exemplary storage medium is coupled to a processor so that the processor can read information from the storage medium and write information to the storage medium. Of course, the storage medium can also be an integral part of the processor. The processor and the storage medium can be located in an application specific integrated circuit (ASIC).
[0145] In the embodiments of the present application, a computer-readable storage medium may be any tangible medium that contains or stores a program, which may be used by or in conjunction with an instruction execution system, apparatus, or device.
[0146] Since the electronic device, computer-readable storage medium, and computer program product in the embodiments of the present application can be applied to the above method, the technical effects that can be obtained can also refer to the above method embodiments, and the embodiments of the present application will not be repeated here.
[0147] The above are only specific implementation methods of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions within the technical scope disclosed in the present application should be included in the protection scope of the present application.
Claims
1. A communication method, characterized in that: Applied to a first client, the method includes: Sending a request for obtaining a communication object to a first server, and receiving a request result corresponding to the request sent by the first server; the first client communicates with the first server through a first communication protocol; The state information of the communication object sent by the second server is received; the first client communicates with the second server via a second communication protocol.
2. The method according to claim 1, characterized in that Before sending the request for acquiring the communication object to the first server, the method further includes: Sending a verification request to the first server; the verification request includes verification information; the verification request is used to instruct the first server to verify the first client; Receive an authentication identifier sent by the first server; the authentication identifier is sent when the first server successfully authenticates the authentication information.
3. The method according to claim 2, characterized in that Before receiving the status information of the communication object sent by the second server, the method further includes: Sending a login request to the second server; the login request includes the authentication identifier; When the second server successfully verifies the authentication identifier, a communication connection with the second server is established.
4. The method according to claim 2, characterized in that: The request includes the authentication identifier; the authentication identifier is used to instruct the first server to determine whether the request result corresponding to the request is the communication object.
5. The method according to claim 1, characterized in that The communication objects include a friend list and / or required files.
6. The method according to claim 5, characterized in that In the case where the communication object includes the friend list, before sending the request for obtaining the communication object to the first server, the method further includes: Receive a friend list update message sent by the second server; the friend list update message is a message sent by the first server and received by the second server; the friend list update message is a message generated by the first server when receiving an operation request sent by the second client; the operation request is used to instruct the first server to perform a target operation on the friend list; the second client is a client to which the friends in the friend list belong.
7. The method according to claim 6, characterized in that The target operation includes at least one of the following: deleting a friend in the friend list, and adding a friend in the friend list.
8. The method according to claim 1, characterized in that The first communication protocol is the Hypertext Transfer Protocol HTTP or the Hypertext Transfer Security Protocol HTTPS, and the second communication protocol is any one of the following: Message Queue Telemetry Transport MQTT, Extensible Messaging and Presentation Protocol XMPP, or Network Sockets Protocol.
9. The method according to claim 5, characterized in that In the case where the communication object includes the friend list, after receiving the status information of the communication object sent by the second server, the method further includes: Send a chat message to the second server; the chat message is a message sent by the first client to the second client; the second client is a client to which the friend in the friend list belongs; the chat message is used to instruct the second server to determine whether to send the chat message to the second client based on the online status of the second client.
10. The method according to claim 9, characterized in that The second server is used for sending the chat message to the second client when the online status of the second client is online.
11. The method according to claim 9, characterized in that The second server is used for storing the chat message when the online status of the second client is offline, and sending the chat message to the second client when the online status of the second client is online.
12. A communication device, characterized in that: Applied to a first client, the communication device comprises: a transmission unit; The transmission unit is used to send a request for obtaining a communication object to the first server, and receive a request result corresponding to the request sent by the first server; the first client communicates with the first server via a first communication protocol; The transmission unit is further used to receive the status information of the communication object sent by the second server; the first client and the second server communicate with each other through a second communication protocol.
13. An electronic device, characterized in that: include: Processor and memory; The memory is used to store one or more programs, and the one or more programs include computer-executable instructions. When the electronic device is running, the processor executes the computer-executable instructions stored in the memory to enable the electronic device to perform the method described in any one of claims 1-11.
14. A computer-readable storage medium storing one or more programs, characterized in that: The one or more programs include instructions which, when executed by a computer, cause the computer to perform the method of any one of claims 1-11.
15. A computer program product, characterized in that The computer program product comprises computer instructions, and when the computer instructions are executed on an electronic device, the electronic device executes the method according to any one of claims 1 to 11.
