Game client seamless reconnection method, device and equipment in weak network environment
Through heartbeat packet detection and reconnection mode, seamless reconnection of game clients in weak network environments is achieved, solving the problems of complexity and message reliability of interrupt line reconnection in the existing technology, and improving system stability and players Experience.
Patent Information
- Application Number
- CN202411257900.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-09
- Publication Date
- 2024-12-31
AI Technical Summary
The existing technology relies on developers to manually write logical code in disconnection processing, which increases the development difficulty and cost. At the same time, the TCP protocol cannot guarantee application-level message reliability and automatic reissue, resulting in game clients in weak network environments. Inadequate stability and reliability.
After establishing a TCP connection between the client and the server, the heartbeat packet is used to detect network abnormalities, trigger the first and second reconnection modes for automatic reconnection, and synchronize the message serial number after the reconnection is successful to reissue untransmitted messages. Achieve seamless reconnection.
It reduces the burden on developers, improves the stability and reliability of network communication systems, ensures the integrity and order of message transmission, improves the game experience of players, and reduces development and maintenance costs.
Smart Images

Figure CN119232780A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of network communication technology, and in particular to a method, device and equipment for seamlessly reconnecting a game client in a weak network environment. Background Art
[0002] In existing network communication systems, the disconnection reconnection mechanism is a key link to ensure service continuity and stability. However, the traditional disconnection reconnection processing method often relies on developers to manually write a large amount of logic code to deal with complex situations such as reconnection attempts, state recovery, and message resending after disconnection. This undoubtedly increases the development difficulty and development cycle, and also increases the cost and complexity of system maintenance. This disconnection reconnection mechanism that relies on developers to implement not only requires developers to have deep network communication knowledge, but also requires a deep understanding of business logic, which leads to a significant increase in development pressure.
[0003] In addition, although TCP (Transmission Control Protocol), as a reliable transmission protocol widely used on the Internet, can provide reliable data transmission services at the operating system level, it does not directly solve the problem of message reliability at the application level. Specifically, TCP cannot guarantee the reliable transmission of messages on the application side, nor can it automatically resend messages that failed to be successfully transmitted due to connection interruption after reconnection. This means that in systems with complex business logic and extremely high requirements for message reliability, it is not enough to rely solely on the reliability of the TCP protocol itself. Additional mechanisms need to be implemented at the application layer to ensure reliable message transmission and message resending after disconnection. Summary of the invention
[0004] In view of this, the purpose of the present invention is to propose a method, device and equipment for seamless reconnection of game clients in a weak network environment, aiming to solve the problem of how to provide an efficient and reliable disconnection reconnection and message resending mechanism to reduce the development pressure of developers and improve the stability and reliability of the network communication system.
[0005] To achieve the above object, the present invention provides a method for seamlessly reconnecting a game client in a weak network environment, the method comprising:
[0006] After the client establishes a network connection with the server through the TCP protocol, the server assigns a corresponding message sequence number according to the generated message and caches it in the message cache pool;
[0007] The client sends a heartbeat packet to the server at a regular interval, and determines whether there is an abnormality in the network connection according to the heartbeat packet;
[0008] When there is an abnormality in the network connection, triggering a first reconnection mode to reconnect, and monitoring whether the reconnection is successful in the first reconnection mode, if not, triggering a second reconnection mode to reconnect, and monitoring whether the reconnection is successful in the second reconnection mode;
[0009] When the reconnection is successful, the client synchronizes the latest message sequence number with the server, and the server selects the to-be-reissued message from the message buffer pool according to the latest message sequence number, and sends the to-be-reissued message to the client.
[0010] Preferably, the client periodically sends a heartbeat packet to the server, and determines whether there is an abnormality in the network connection according to the heartbeat packet, including:
[0011] Detect whether the heartbeat packet sent by the client receives a reply from the server. If not, determine whether the number of times the heartbeat packet is lost exceeds a loss threshold. If so, determine that there is an abnormality in the network connection.
[0012] Preferably, when there is an abnormality in the network connection, triggering the first reconnection mode to reconnect, and monitoring whether the reconnection is successful in the first reconnection mode includes:
[0013] The client manages the reconnection interval by disconnecting the current network connection and creating a pre-reconnection timer;
[0014] The client initiates a reconnection request, requests to re-establish a network connection with the server according to the reconnection request, and determines whether the reconnection is successful;
[0015] If not, accumulating the number of pre-reconnection times and determining that the number of pre-reconnection times does not exceed the first reconnection threshold, continue to send the reconnection request after reaching the reconnection interval;
[0016] If it is determined that the pre-reconnection times exceeds the reconnection threshold, the second reconnection mode is triggered.
[0017] Preferably, triggering the second reconnection mode to reconnect, and monitoring whether the reconnection is successful in the second reconnection mode, includes:
[0018] The client disconnects the current network connection and initiates a reconnection request in the reconnection interface, and determines whether the reconnection is successful;
[0019] If not, accumulating the number of formal reconnections and determining that the number of formal reconnections does not exceed the second reconnection threshold, continue to send reconnection requests after the user confirms that he / she chooses to continue reconnecting;
[0020] If it is determined that the number of formal reconnections exceeds the second reconnection threshold, return to the login interface to log in again.
[0021] Preferably, the caching mechanism of the message cache pool includes caching each message sent by the server to the client in the message cache pool, and after the server obtains confirmation information that the client has received the corresponding message, the server deletes the corresponding message from the message cache pool according to the confirmation information.
[0022] Preferably, the method further comprises:
[0023] The server monitors whether the messages in the message buffer pool have reached a buffer upper limit, and if so, notifies the client to log in again.
[0024] To achieve the above object, the present invention further provides a device for seamlessly reconnecting a game client in a weak network environment, the device comprising:
[0025] A connection establishment unit is used for, after the client establishes a network connection with the server through the TCP protocol, to allocate a corresponding message sequence number according to the generated message through the server and cache it in a message cache pool;
[0026] A heartbeat packet detection unit, used for the client to periodically send a heartbeat packet to the server, and to determine whether there is an abnormality in the network connection according to the heartbeat packet;
[0027] a reconnection initiation unit, configured to trigger a first reconnection mode for reconnection when an abnormality occurs in the network connection, and monitor whether the reconnection is successful in the first reconnection mode; if not, trigger a second reconnection mode for reconnection, and monitor whether the reconnection is successful in the second reconnection mode;
[0028] The message synchronization unit is used for synchronizing the latest message sequence number from the client to the server when the reconnection is successful, and the server selects the to-be-reissued message from the message buffer pool according to the latest message sequence number and sends the to-be-reissued message to the client.
[0029] In order to achieve the above-mentioned objectives, the present invention also proposes a seamless reconnection device for a game client in a weak network environment, comprising a processor, a memory, and a computer program stored in the memory, wherein the computer program is executed by the processor to implement the steps of a method for seamless reconnection of a game client in a weak network environment as described in the above-mentioned embodiment.
[0030] In order to achieve the above objectives, the present invention also proposes a computer-readable storage medium, on which a computer program is stored, and the computer program is executed by a processor to implement the steps of a method for seamless reconnection of a game client in a weak network environment as described in the above embodiment.
[0031] In order to achieve the above objectives, the present invention also proposes a computer program product, including a computer program / instruction, which, when executed by a processor, implements the steps of a method for seamless reconnection of a game client in a weak network environment as described in the above embodiment.
[0032] Beneficial effects:
[0033] The above solution can achieve seamless reconnection of the game client in a weak network environment, allowing players to continue playing games when network conditions are poor, and the client can automatically and quickly restore the connection with the server without frequent re-login, thus avoiding game interruptions and significantly improving the player's gaming experience. At the same time, this method implements an automated reconnection mechanism, including pre-reconnection and formal reconnection modes, which reduces the burden of network exception handling on developers, simplifies the business development process, reduces development costs and maintenance difficulties, and thus improves development efficiency.
[0034] The above scheme can detect and respond to network anomalies in a timely manner by regularly sending heartbeat packets and judging the network connection status based on them, effectively avoiding connection interruptions caused by network fluctuations, and enhancing the stability and reliability of network connections. In addition, the network connection is determined to be abnormal based on the heartbeat packet reply to start the reconnection mode, making the reconnection process more flexible and efficient, reducing unnecessary network requests and resource consumption.
[0035] The above solution, through the synchronization of message sequence numbers and the caching mechanism of messages in the message buffer pool, can ensure that after reconnection, the client can also receive all untransmitted messages, thereby ensuring the integrity and sequence of message transmission, which is especially important for games that require real-time synchronization status.
[0036] The above solution avoids the problem of resource exhaustion on the server side due to caching too many messages by monitoring the upper limit of messages in the message cache pool and notifying the client to log in again in a timely manner, thereby protecting the stable operation of the server side. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0038] Figure 1 A flowchart of a method for seamlessly reconnecting a game client in a weak network environment is provided in accordance with an embodiment of the present invention.
[0039] Figure 2 A schematic diagram of an overall reconnection process provided by an embodiment of the present invention.
[0040] Figure 3 A schematic diagram of the structure of a device for seamlessly reconnecting a game client in a weak network environment provided by one embodiment of the present invention.
[0041] The realization of the purpose, functional features and advantages of the invention will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0042] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, rather than all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention. Therefore, the following detailed description of the embodiments of the present invention provided in the drawings is not intended to limit the scope of the invention claimed for protection, but merely represents the selected embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.
[0043] In the description of the present invention, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" and "second" may explicitly or implicitly include one or more of the features.
[0044] The content of the present invention is described in detail below with reference to embodiments.
[0045] Reference Figure 1 The figure is a flow chart of a method for seamlessly reconnecting a game client in a weak network environment provided by one embodiment of the present invention.
[0046] In this embodiment, the method includes:
[0047] S11, after the client establishes a network connection with the server through the TCP protocol, the server allocates a corresponding message sequence number according to the generated message and caches it in a message cache pool.
[0048] S12, the client sends a heartbeat packet to the server at a regular interval, and determines whether there is an abnormality in the network connection based on the heartbeat packet.
[0049] Furthermore, the cache mechanism of the message cache pool includes caching each message sent by the server to the client in the message cache pool. After the server obtains confirmation information that the client has received the corresponding message, the server deletes the corresponding message from the message cache pool according to the confirmation information.
[0050] Further, in step S12, the client periodically sends a heartbeat packet to the server, and determines whether there is an abnormality in the network connection according to the heartbeat packet, including:
[0051] Detect whether the heartbeat packet sent by the client receives a reply from the server. If not, determine whether the number of times the heartbeat packet is lost exceeds a loss threshold. If so, determine that there is an abnormality in the network connection.
[0052] In this embodiment, seamless reconnection relies on the TCP network protocol. The client and the server establish a network connection based on the TCP protocol to ensure a stable communication channel, and use its connection-oriented characteristics to ensure the reliability and orderliness of data transmission. After the network connection is established, both ends use heartbeat packets to monitor the network connection status in real time. The client will periodically send heartbeat packets to the server to determine whether the network connection is abnormal. If the number of heartbeat packet losses exceeds a certain number, the reconnection link will be entered. For example, when the heartbeat packet is lost for three or more consecutive times, the system will automatically trigger the reconnection process.
[0053] Reference Figure 2 As shown, after the system is started, the client establishes a network connection with the server, and the client sends a heartbeat packet to the server to keep the network connection active; the client waits for the server to reply to the heartbeat packet, and determines whether the reply from the server is received; if so, it indicates that the network connection is normal, clears the lost heartbeat packet count and continues to send the next heartbeat packet to the server at a regular interval, if not, the heartbeat packet loss count is increased, and it is determined whether the number of heartbeat packet losses exceeds the preset loss threshold; if not, the heartbeat packet continues to be sent and waits for a reply, if it exceeds, it is determined that there is an abnormality in the network connection and enters the pre-reconnection mode (the first reconnection mode).
[0054] Each time the server sends a message to the client, it will first cache the message in the message cache pool; after the client receives the message normally, it will send a confirmation message to the server to confirm that it has received one or more messages. The server will delete the corresponding message from the message cache pool based on the confirmation information.
[0055] S13, when there is an abnormality in the network connection, trigger the first reconnection mode to reconnect, and monitor whether the reconnection is successful in the first reconnection mode. If not, trigger the second reconnection mode to reconnect, and monitor whether the reconnection is successful in the second reconnection mode.
[0056] Further, in step S13, when there is an abnormality in the network connection, triggering the first reconnection mode to reconnect, and monitoring whether the reconnection is successful in the first reconnection mode includes:
[0057] The client manages the reconnection interval by disconnecting the current network connection and creating a pre-reconnection timer;
[0058] The client initiates a reconnection request, requests to re-establish a network connection with the server according to the reconnection request, and determines whether the reconnection is successful;
[0059] If not, accumulating the number of pre-reconnection times and determining that the number of pre-reconnection times does not exceed the first reconnection threshold, continue to send the reconnection request after reaching the reconnection interval;
[0060] If it is determined that the pre-reconnection times exceeds the reconnection threshold, the second reconnection mode is triggered.
[0061] Further, in step S13, triggering the second reconnection mode to reconnect, and monitoring whether the reconnection is successful in the second reconnection mode includes:
[0062] The client disconnects the current network connection and initiates a reconnection request in the reconnection interface, and determines whether the reconnection is successful;
[0063] If not, accumulating the number of formal reconnections and determining that the number of formal reconnections does not exceed the second reconnection threshold, continue to send reconnection requests after the user confirms that he / she chooses to continue reconnecting;
[0064] If it is determined that the number of formal reconnections exceeds the second reconnection threshold, return to the login interface to log in again.
[0065] In this embodiment, when it is determined that the number of heartbeat packet losses exceeds the preset upper limit of the loss count, the network connection is determined to be abnormal, and the system will automatically trigger the seamless reconnection process. In other embodiments, in addition to the number of heartbeat packet losses exceeding the loss threshold, the pre-reconnection mode can also be triggered by changes in the activation state of the game window or detection of a network connection error. When the pre-reconnection fails or the client actively initiates a request to the server when the heartbeat packet is lost, the formal reconnection mode is triggered. However, the pre-reconnection mode is performed silently in the background, does not affect the player's current operation, and achieves a seamless reconnection; the formal reconnection mode will suspend all player operations and display the reconnection interface.
[0066] Reference Figure 2As shown. The client first disconnects the current network connection and creates a pre-reconnection timer to manage the retry interval of the reconnection attempt; the client initiates a reconnection request and continuously tries to establish a connection with the server; and determines whether the reconnection is successful. If the reconnection is successful, the pre-reconnection count is cleared, the pre-reconnection timer is cleared, and the latest message sequence number MsgIndex is synchronized to the server to enter the data synchronization process. If the reconnection fails, the pre-reconnection count increases and determines whether it exceeds the preset pre-reconnection failure limit; if it does not exceed, wait for the pre-reconnection timer to be triggered and try to reconnect again. If it exceeds, enter the formal reconnection mode (second reconnection mode). Before entering the formal reconnection mode, clear the count of lost heartbeat packets, clear the pre-reconnection timer, and clear the pre-reconnection count.
[0067] When the pre-reconnection times out or fails, the client will actively initiate a formal reconnection request. Specifically, the client disconnects the current network connection and initiates a reconnection request in the displayed reconnection interface; after the formal reconnection request is sent, it is determined whether the reconnection is successful. If the reconnection is successful, the latest message sequence number is synchronized to the server to enter the data synchronization process to process the message resend. If the reconnection fails, the formal reconnection count increases; it is determined whether the number of formal reconnections exceeds the preset formal reconnection failure limit. If not, wait for the user to confirm again whether to choose to continue reconnecting. If it exceeds, return to the login interface and ask the user to log in again.
[0068] S14, when the reconnection is successful, the client synchronizes the latest message sequence number with the server, and the server selects the to-be-reissued message from the message buffer pool according to the latest message sequence number, and sends the to-be-reissued message to the client.
[0069] In this embodiment, the server uses the message sequence number MsgIndex as the unique identifier of the message and caches the sent messages. The client brings the maximum MsgIndex received in the next request, and the server clears the cached messages whose message sequence numbers are less than the maximum MsgIndex according to the maximum MsgIndex, thereby controlling the validity and size of the message cache pool.
[0070] When the reconnection is successful (pre-reconnection mode reconnection is successful or formal reconnection mode reconnection is successful), the client synchronizes the latest message sequence number to the server. The server selects the messages to be resent from the messages cached in the message buffer pool according to the message sequence number, and sends these messages to the client in sequence (the message sequence number MsgIndex adopts a cumulative confirmation method. When the server receives a certain MsgIndex sent by the client, it means that the messages with message sequence numbers less than or equal to the MsgIndex have been received by the client. Then the server needs to resend the messages between the latest MsgIndex and the received MsgIndex), ensuring seamless recovery of the game status and improving the orderliness and reliability of information interaction between the two ends.
[0071] Furthermore, the method further comprises:
[0072] S15, the server monitors whether the messages in the message buffer pool have reached the buffer upper limit, and if so, notifies the client to log in again.
[0073] In this embodiment, due to the excessive amount of messages accumulated during the client disconnection process, the message cache pressure on the server will be too high, resulting in instability of the server. Therefore, in order to prevent too many cached messages, the server sets a cache upper limit for each player. Once the cache upper limit is exceeded, the server will not continue to cache the messages that need to be sent to this client, and notify the client to perform a forced re-login operation to update the data and various states cached by the client, so as to reduce the storage pressure of the server. During the re-login process, when the server and the client have not successfully reconnected, the server will add the messages that need to be sent to the client during this period to the message cache pool and mark them as unsent; when the connection is re-established with the client, the server will send these unsent messages to the client, and continue to store the unsent messages in the message cache pool waiting for the client to confirm. It should be noted that since the message cache size allocated to each client by the server is capped, when the server finds that the cached messages belonging to a certain client have reached the upper limit, it will stop caching, and after the client reconnects to the server, it will send a special message to the client to notify the client to force a re-login. When the client logs out of the current login state, the server will clear all cached messages.
[0074] Reference Figure 3 It is a schematic diagram of the structure of a seamless reconnection device for a game client in a weak network environment provided by one embodiment of the present invention.
[0075] In this embodiment, the device 20 includes:
[0076] A connection establishment unit 21 is used for, after the client establishes a network connection with the server through the TCP protocol, to assign a corresponding message sequence number according to the generated message through the server and cache it in a message cache pool;
[0077] A heartbeat packet detection unit 22, configured for the client to periodically send a heartbeat packet to the server, and to determine whether there is an abnormality in the network connection according to the heartbeat packet;
[0078] a reconnection initiation unit 23, configured to trigger a first reconnection mode for reconnection when an abnormality occurs in the network connection, and monitor whether the reconnection is successful in the first reconnection mode; if not, trigger a second reconnection mode for reconnection, and monitor whether the reconnection is successful in the second reconnection mode;
[0079] The message synchronization unit 24 is used for synchronizing the latest message sequence number from the client to the server when the reconnection is successful, and the server selects the to-be-reissued message from the message buffer pool according to the latest message sequence number and sends the to-be-reissued message to the client.
[0080] In another embodiment, the device 20 further comprises:
[0081] The cache monitoring unit 25 is used for the server to monitor whether the messages in the message cache pool have reached the cache upper limit, and if so, to notify the client to log in again.
[0082] Each unit module of the device 20 can respectively execute the corresponding steps in the above method embodiment, so each unit module will not be described in detail here. Please refer to the description of the above corresponding steps for details.
[0083] The embodiment of the present invention further provides a device for seamlessly reconnecting a game client in a weak network environment. The device includes the device for seamlessly reconnecting a game client in a weak network environment as described above. The device for seamlessly reconnecting a game client in a weak network environment can be used. Figure 3 The structure of the embodiment can be executed accordingly. Figure 1 The technical solution of the method embodiment shown has similar implementation principles and technical effects. For details, please refer to the relevant records in the above embodiments, which will not be repeated here.
[0084] The device includes: a mobile phone, a digital camera, a tablet computer, or other devices with a camera function, or a device with an image processing function, or a device with an image display function. The device may include components such as a memory, a processor, an input unit, a display unit, and a power supply.
[0085] Among them, the memory can be used to store software programs and modules, and the processor executes various functional applications and data processing by running the software programs and modules stored in the memory. The memory may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function (such as an image playback function, etc.), etc.; the data storage area may store data created according to the use of the device, etc. In addition, the memory may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices. Accordingly, the memory may also include a memory controller to provide the processor and the input unit with access to the memory.
[0086] The input unit can be used to receive input digital or character or image information, and generate keyboard, mouse, joystick, optical or trackball signal input related to user settings and function control. Specifically, the input unit of this embodiment includes not only a camera, but also a touch-sensitive surface (such as a touch display) and other input devices.
[0087] The display unit can be used to display information input by the user or information provided to the user and various graphical user interfaces of the device, which can be composed of graphics, text, icons, videos and any combination thereof. The display unit may include a display panel, and optionally, the display panel may be configured in the form of LCD (Liquid Crystal Display), OLED (Organic Light-Emitting Diode), etc. Further, the touch-sensitive surface may cover the display panel, and when the touch-sensitive surface detects a touch operation on or near it, it is transmitted to the processor to determine the type of touch event, and then the processor provides a corresponding visual output on the display panel according to the type of touch event.
[0088] The embodiment of the present invention further provides a computer-readable storage medium, which may be a computer-readable storage medium included in the memory in the above embodiment; or a computer-readable storage medium that exists independently and is not installed in a device. The computer-readable storage medium stores at least one instruction, which is loaded and executed by a processor to implement Figure 1 The computer-readable storage medium may be a read-only memory, a disk or an optical disk, etc.
[0089] The embodiment of the present invention also provides a computer program product, including a computer program / instruction, which is loaded and executed by a processor to implement Figure 1 A method for seamlessly reconnecting a game client in a weak network environment is shown.
[0090] It should be noted that each embodiment in this specification is described in a progressive manner, and each embodiment focuses on the differences from other embodiments, and the same or similar parts between the embodiments can be referred to each other. For the device embodiment, equipment embodiment and storage medium embodiment, since they are basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0091] Furthermore, in this document, the terms "comprises," "comprising," or any other variation thereof are intended to encompass non-exclusive inclusion, such that a process, method, article, or device that includes a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or device. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of additional identical elements in the process, method, article, or device that includes the element.
[0092] The above description shows and describes the preferred embodiments of the present invention. It should be understood that the present invention is not limited to the form disclosed herein, and should not be regarded as excluding other embodiments, but can be used in various other combinations, modifications and environments, and can be modified within the scope of the invention, through the above teachings or the technology or knowledge of the relevant field. The changes and modifications made by those skilled in the art shall not depart from the spirit and scope of the present invention, and shall be within the scope of protection of the claims attached to the present invention.
Claims
1. A method for seamless reconnection of a game client in a weak network environment, characterized in that: The method comprises: After the client establishes a network connection with the server through the TCP protocol, the server assigns a corresponding message sequence number according to the generated message and caches it in the message cache pool; The client sends a heartbeat packet to the server at a regular interval, and determines whether there is an abnormality in the network connection according to the heartbeat packet; When there is an abnormality in the network connection, triggering a first reconnection mode to reconnect, and monitoring whether the reconnection is successful in the first reconnection mode, if not, triggering a second reconnection mode to reconnect, and monitoring whether the reconnection is successful in the second reconnection mode; When the reconnection is successful, the client synchronizes the latest message sequence number with the server, and the server selects the to-be-reissued message from the message buffer pool according to the latest message sequence number, and sends the to-be-reissued message to the client.
2. According to the method for seamless reconnection of a game client in a weak network environment according to claim 1, it is characterized in that: The client periodically sends a heartbeat packet to the server, and determines whether there is an abnormality in the network connection according to the heartbeat packet, including: Detect whether the heartbeat packet sent by the client receives a reply from the server. If not, determine whether the number of times the heartbeat packet is lost exceeds a loss threshold. If so, determine that there is an abnormality in the network connection.
3. According to the method for seamless reconnection of a game client in a weak network environment as described in claim 1, it is characterized in that: When the network connection is abnormal, triggering the first reconnection mode to reconnect, and monitoring whether the reconnection is successful in the first reconnection mode, includes: The client manages the reconnection interval by disconnecting the current network connection and creating a pre-reconnection timer; The client initiates a reconnection request, requests to re-establish a network connection with the server according to the reconnection request, and determines whether the reconnection is successful; If not, accumulating the number of pre-reconnection times and determining that the number of pre-reconnection times does not exceed the first reconnection threshold, continue to send the reconnection request after reaching the reconnection interval; If it is determined that the pre-reconnection times exceeds the reconnection threshold, the second reconnection mode is triggered.
4. A method for seamlessly reconnecting a game client in a weak network environment according to claim 1 or 3, characterized in that: The triggering of the second reconnection mode to perform reconnection, and monitoring whether the reconnection is successful in the second reconnection mode, includes: The client disconnects the current network connection and initiates a reconnection request in the reconnection interface, and determines whether the reconnection is successful; If not, accumulating the number of formal reconnections and determining that the number of formal reconnections does not exceed the second reconnection threshold, continue to send reconnection requests after the user confirms that he / she chooses to continue reconnecting; If it is determined that the number of formal reconnections exceeds the second reconnection threshold, return to the login interface to log in again.
5. The method for seamlessly reconnecting a game client in a weak network environment according to claim 1, characterized in that: The cache mechanism of the message cache pool includes caching each message sent by the server to the client in the message cache pool. After the server obtains confirmation information that the client has received the corresponding message, the server deletes the corresponding message from the message cache pool according to the confirmation information.
6. The method for seamlessly reconnecting a game client in a weak network environment according to claim 1, characterized in that: The method further comprises: The server monitors whether the messages in the message buffer pool have reached a buffer upper limit, and if so, notifies the client to log in again.
7. A seamless reconnection device for a game client in a weak network environment, characterized in that: The device comprises: A connection establishment unit is used for, after the client establishes a network connection with the server through the TCP protocol, to allocate a corresponding message sequence number according to the generated message through the server and cache it in a message cache pool; A heartbeat packet detection unit, used for the client to periodically send a heartbeat packet to the server, and to determine whether there is an abnormality in the network connection according to the heartbeat packet; a reconnection initiation unit, configured to trigger a first reconnection mode for reconnection when an abnormality occurs in the network connection, and monitor whether the reconnection is successful in the first reconnection mode; if not, trigger a second reconnection mode for reconnection, and monitor whether the reconnection is successful in the second reconnection mode; The message synchronization unit is used for synchronizing the latest message sequence number from the client to the server when the reconnection is successful, and the server selects the to-be-reissued message from the message buffer pool according to the latest message sequence number and sends the to-be-reissued message to the client.
8. A seamless reconnection device for a game client in a weak network environment, characterized in that: It includes a processor, a memory and a computer program stored in the memory, wherein the computer program is executed by the processor to implement the steps of a method for seamless reconnection of a game client in a weak network environment as described in any one of claims 1 to 6.
9. A computer program product, comprising a computer program / instruction, wherein the computer program / instruction is executed by a processor to implement the steps of a method for seamless reconnection of a game client in a weak network environment as described in any one of claims 1 to 6.
Citation Information
Cited By
WS disconnection message processing method and device, computer equipment and medium
CN121239729A
