A kind of method and device of disconnection reconnectingTechnical field
The present invention relates to the technical field of mobile interchange more particularly to a kind of method and devices of disconnection reconnecting.
Background technology
With the development of development of Mobile Internet technology, 4G networks are widely available, mobile terminal (such as:Smart mobile phone)Networking speed is getting faster, and people also get used to playing online game using mobile Internet.
" disconnection reconnecting " is the technology often to be used in online game, and in mobile phone suspension, game client can be with tripServer of playing is out of touch (i.e.:Broken string), it at this moment just needs game client to be re-established with game server and connect, this is alsoIt is " disconnection reconnecting ".
Currently, when carrying out disconnection reconnecting, the broadcast message that cell phone system issues is mainly based upon to realize.ButWhen mobile phone suspension, cell phone system can be issued continuously and be broadcast the message three times, and wherein have twice broadcast message be the same, this can leadCause the processing logical miss of game client, game client needs to establish to be reconnected twice, it is then primary again can will it is preceding onceIt pushes away, this is undoubtedly speed that is nonsensical, and can also reducing reconnection, the burden of heavy system.
Invention content
The embodiment of the present application solves and is breaking in the prior art by providing a kind of method and device of disconnection reconnectingWhen line reconnection, there are processing logical miss, and reconnection speed is slower, and the heavier technical problem of system burden is realized and carried outWhen disconnection reconnecting, clear logic is handled, mitigates system burden, improves the technique effect of reconnection speed.
In a first aspect, the application is provided the following technical solutions by the embodiment of the application:
A kind of method of disconnection reconnecting, including:
In client and server networking process, the network state of mobile terminal is monitored by monitoring module,Wherein, the client is mounted in the system of the mobile terminal, and the monitoring module is arranged in the client;
When the network for finding the mobile terminal occurs abnormal, it is to the mobile terminal by the monitoring moduleSystem sends a presetting message;
The presetting message is received by reconnection module, and is based on the presetting message, judges the net of the mobile terminalWhether network restores normal, wherein the reconnection module is arranged in the client;
If the network recovery of the mobile terminal is normal, the client and institute are re-established by the reconnection moduleState the network connection between server.
Preferably, described that the network state of mobile terminal is monitored by monitoring module, including:
It is monitored by monitoring the broadcast message that module issues the system, is disappeared if receiving the first default broadcastBreath, it is determined that the network of the mobile terminal occurs abnormal;Or
It is monitored by monitoring socket connection of the module between the client and the server, if finding instituteThe socket connections broken string stated, it is determined that the network of the mobile terminal occurs abnormal.
Preferably, described that a presetting message is sent to the system of the mobile terminal by the monitoring module, including:
It is each every preset time period before the network recovery of the mobile terminal is normal, by the monitoring module toThe system of the mobile terminal sends the presetting message.
Preferably, the preset time period is 2~4 seconds.
Preferably, described that the presetting message is sent to the system of the mobile terminal by the monitoring module, including:
By monitoring module based on handle message processing facilities by logical state, institute is sent to the system of the mobile terminalState presetting message;Or
The presetting message is sent to the system of the mobile terminal by broadcast by the monitoring module.
Preferably, the presetting message is null message.
Second aspect, the application are provided the following technical solutions by the embodiment of the application:
A kind of device of disconnection reconnecting, including:
Module is monitored, in client and server networking process, monitoring the network state of mobile terminal,Wherein, the client is mounted in the system of the mobile terminal, and the monitoring module is arranged in the client;It is sending outWhen the network of the existing mobile terminal occurs abnormal, a presetting message is sent to the system of the mobile terminal;
Reconnection module for receiving the presetting message, and is based on the presetting message, judges the net of the mobile terminalWhether network restores normal, wherein the reconnection module is arranged in the client;If the network recovery of the mobile terminal is justOften, then the network connection between the client and the server is re-established.
Preferably, the monitoring module, is specifically used for:
The broadcast message issued to the system is monitored, if receiving the first default broadcast message, it is determined that describedThe network of mobile terminal occurs abnormal;Or the socket connections between the client and the server are monitored, ifIt was found that the socket connections broken string, it is determined that the network of the mobile terminal occurs abnormal.
The third aspect, the application are provided the following technical solutions by the embodiment of the application:
A kind of device of disconnection reconnecting, including memory, processor and storage can transport on a memory and on a processorCapable computer program, the processor realize following steps when executing the computer program:
In client and server networking process, the network state of mobile terminal is monitored by monitoring module,Wherein, the client is mounted in the system of the mobile terminal, and the monitoring module is arranged in the client;It is sending outWhen the network of the existing mobile terminal occurs abnormal, one is sent to the system of the mobile terminal by the monitoring module and presetMessage;The presetting message is received by reconnection module, and is based on the presetting message, judges that the network of the mobile terminal isIt is no to restore normal, wherein the reconnection module is arranged in the client;If the network recovery of the mobile terminal is normal,The network connection between the client and the server is then re-established by the reconnection module.
Fourth aspect, the application are provided the following technical solutions by the embodiment of the application:
A kind of computer readable storage medium, is stored thereon with computer program, and the computer program is held by processorFollowing steps are realized when row:
In client and server networking process, the network state of mobile terminal is monitored by monitoring module,Wherein, the client is mounted in the system of the mobile terminal, and the monitoring module is arranged in the client;It is sending outWhen the network of the existing mobile terminal occurs abnormal, one is sent to the system of the mobile terminal by the monitoring module and presetMessage;The presetting message is received by reconnection module, and is based on the presetting message, judges that the network of the mobile terminal isIt is no to restore normal, wherein the reconnection module is arranged in the client;If the network recovery of the mobile terminal is normal,The network connection between the client and the server is then re-established by the reconnection module.
One or more technical solutions provided in the embodiments of the present application have at least the following technical effects or advantages:
In the embodiment of the present application, a kind of method of disconnection reconnecting is disclosed, including:It networked in client and serverCheng Zhong monitors module and monitors the network state of mobile terminal, wherein client is mounted in the system of dynamic terminal, prisonListen module setting in the client;When the network for finding mobile terminal occurs abnormal, system of the module to mobile terminal is monitoredSend a presetting message;Reconnection module receives presetting message, and is based on presetting message, re-establishes between client and serverNetwork connection, wherein reconnection module be arranged in the client.Due to when carrying out disconnection reconnecting, not depending on mobile phone systemThe broadcast message that system issues, therefore avoid processing logic and cause confusion, it is reconnected twice without establishing, and then improve reconnectionSpeed is connect, system burden is alleviated.So solve in the prior art when carrying out disconnection reconnecting, there are processing logical miss,Reconnection speed is slower, and the technical problem of system burden weight realizes when carrying out disconnection reconnecting, handles clear logic, mitigatesSystem burden improves the technique effect of reconnection speed.
Description of the drawings
To describe the technical solutions in the embodiments of the present invention more clearly, make required in being described below to embodimentAttached drawing is briefly described, it should be apparent that, drawings in the following description are some embodiments of the invention, for thisFor the those of ordinary skill of field, without creative efforts, others are can also be obtained according to these attached drawingsAttached drawing.
Fig. 1 is a kind of flow chart of the method for disconnection reconnecting in the embodiment of the present application;
Fig. 2 is a kind of structure chart of the device of disconnection reconnecting in the embodiment of the present application;
Fig. 3 is a kind of structure chart of the device of disconnection reconnecting in the embodiment of the present application;
Fig. 4 is a kind of structure chart of computer readable storage medium in the embodiment of the present application.
Specific implementation mode
The embodiment of the present application solves and is breaking in the prior art by providing a kind of method and device of disconnection reconnectingWhen line reconnection, there are processing logical miss, and reconnection speed is slower, and the heavier technical problem of system burden is realized and carried outWhen disconnection reconnecting, clear logic is handled, mitigates system burden, improves the technique effect of reconnection speed.
The technical solution of the embodiment of the present application is in order to solve the above technical problems, general thought is as follows:
A kind of method of disconnection reconnecting, including:In client and server networking process, module is monitored to mobile terminalNetwork state monitored, wherein the client is mounted in the system of the mobile terminal, and the monitorings module is arrangedIn the client;When the network for finding the mobile terminal occurs abnormal, the monitoring module is to the mobile terminalSystem send a presetting message;Reconnection module receives the presetting message, and is based on the presetting message, re-establishes describedNetwork connection between client and the server, wherein the reconnection module is arranged in the client.
In order to better understand the above technical scheme, in conjunction with appended figures and specific embodiments to upperTechnical solution is stated to be described in detail.
Embodiment one
A kind of method of disconnection reconnecting is present embodiments provided, is applied in mobile terminal, the mobile terminal can beWhich kind of equipment smart mobile phone or tablet computer, game machine etc., be specifically for the mobile terminal, and the present embodiment is not made to haveBody limits.Wherein, be equipped in the mobile terminal operating system (such as:Android system or IOS systems), and at thisOne client is installed, the executive agent of the method for the disconnection reconnecting in the present embodiment is the client in operating system.
As shown in Figure 1, the method for the disconnection reconnecting, including:
Step S101:In client and server networking process, monitors module and the network state of mobile terminal is carried outIt monitors, wherein client is mounted in the system of mobile terminal, monitors module setting in the client.
In specific implementation process, which can be (network) game client, and user is played using mobile terminalWhen online game, client then need with server (such as:Game proxy server) it networks.Alternatively, the clientCan be network direct broadcasting platform (such as:" bucket fish " live streaming platform) client, user can play play when, open simultaneously thisClient, and game picture is broadcast live by the network direct broadcasting platform.
In specific implementation process, in the client setting there are two module (i.e.:Monitor module and reconnection module), thisTwo modules can be run by different threads.Wherein, module is monitored to be responsible for monitoring the network state of mobile terminal,Reconnection module is responsible for, when client and server break, establishing and connecting with server again.
As a kind of optional embodiment, the monitoring module monitors the network state of mobile terminal, including:
It monitors socket connection of the module between client and server to monitor, if the socket connections found are disconnectedLine, it is determined that the network of mobile terminal occurs abnormal.
In specific implementation process, mobile terminal can be linked into mobile operator (such as:" unicom " or " movement " or" telecommunications ") mobile network connection (such as:3G network or 4G networks) in, still, since mobile network is not comprehensive in the presence of coveringRegion, mobile terminal is the case where these regions are then susceptible to suspension.
In specific implementation process, monitors module and be responsible for monitoring the network state of mobile terminal.Specifically, it supervisesListen module that can monitor the socket connections between client and server, in game process, clientThe socket of socket and server is in connection status, as long as mobile terminal suspension, which will break,Socket will report an error, at this point, monitor module then can know that socket breaks according to the error information, also just know movementThere is exception in the network of terminal.
Step S102:When the network for finding mobile terminal occurs abnormal, monitors module and sent to the system of mobile terminalOne presetting message.
As a kind of optional embodiment, the monitoring module sends a presetting message to the system of mobile terminal, including:
Before the network recovery of mobile terminal is normal (i.e.:When the network of mobile terminal occurs abnormal), monitoring module canEvery a preset time period, presetting message is sent to the system of mobile terminal.
In specific implementation process, monitors module and can be created based on the handle message processing facilities in android systemA handle objects are built, and primary preset is sent to the system of mobile terminal every a preset time period using the handle objectsMessage;Alternatively, one can also be sent by way of broadcast every a preset time period to the system of mobile terminal by monitoring moduleSecondary presetting message.Herein, operated in different threads due to reconnection module from module is monitored, thus using handle mechanism orThe message transmission of cross-thread may be implemented in the mode of broadcast.
In specific implementation process, the value range of the preset time is:2 seconds~4 seconds (such as:2 seconds or 3 seconds.Or 4Second, etc.).Herein, if frequency is too high, system burden is overweight, and excessively high frequency is also nonsensical;If frequency is too low,The speed of reconnection is too slow, can be affected greatly to game running, and the impression of user is also bad.It preferably 3 seconds, not only can be withIt realizes quick reconnection, reduces the influence to game running, when user being made not yet to realize (or upon realizing) broken string, just againIt is connected to, while will not heavy system burden.
In specific implementation process, the presetting message can be with an agreement message, it is preferable that and can be null message herein,The data volume that message can be reduced in this way improves the transmitting-receiving speed of message.
For example, before the network recovery of mobile terminal is normal, monitoring module can be every 3 second to mobile terminalSystem send a null message.
Step S103:Reconnection module receives presetting message, and is based on the presetting message, re-establishes client and serverBetween network connection.
In specific implementation process, reconnection module often receive the primary presetting message (such as:Null message), then can attempt withServer re-establishes primary network connection (i.e.:Socket connections), if can connect, represent the network recovery of mobile terminalNormally, client then can be communicated normally with server, if Lian Bushang, the network for representing mobile terminal is still depositedIn exception, then needs to continue waiting for next 3 seconds, primary network is re-established after receiving the presetting message, then with serverConnection.
In the present embodiment, when carrying out disconnection reconnecting, the system of not depending on issues broadcast message, therefore avoids processing and patrolIt collects and causes confusion, reconnected twice without establishing, and then improve reconnection speed, alleviate system burden.
Technical solution in above-mentioned the embodiment of the present application, at least has the following technical effect that or advantage:
In the embodiment of the present application, a kind of method of disconnection reconnecting is disclosed, including:It networked in client and serverCheng Zhong monitors module and monitors the network state of mobile terminal, wherein client is mounted in the system of dynamic terminal, prisonListen module setting in the client;When the network for finding mobile terminal occurs abnormal, system of the module to mobile terminal is monitoredSend a presetting message;Reconnection module receives presetting message, and is based on presetting message, re-establishes between client and serverNetwork connection, wherein reconnection module be arranged in the client.Due to when carrying out disconnection reconnecting, not depending on mobile phone systemThe broadcast message that system issues, therefore avoid processing logic and cause confusion, it is reconnected twice without establishing, and then improve reconnectionSpeed is connect, system burden is alleviated.So solve in the prior art when carrying out disconnection reconnecting, there are processing logical miss,Reconnection speed is slower, and the technical problem of system burden weight realizes when carrying out disconnection reconnecting, handles clear logic, mitigatesSystem burden improves the technique effect of reconnection speed.
Embodiment two
Based on same inventive concept, a kind of device 200 of disconnection reconnecting is present embodiments provided, as shown in Fig. 2, including:
Module 201 is monitored, in client and server networking process, being supervised to the network state of mobile terminalIt listens, wherein the client is mounted in the system of the mobile terminal, and the monitoring module is arranged in the client;When the network for finding the mobile terminal occurs abnormal, a presetting message is sent to the system of the mobile terminal;
Reconnection module 202 for receiving the presetting message, and is based on the presetting message, re-establishes the clientNetwork connection between end and the server, wherein the reconnection module is arranged in the client.
As a kind of optional embodiment, module 201 is monitored, is specifically used for:
Socket connections between the client and the server are monitored, if finding, the socket connectsConnect broken string, it is determined that the network of the mobile terminal occurs abnormal.
As a kind of optional embodiment, module 201 is monitored, is specifically used for:
Before the network recovery of the mobile terminal is normal, every a preset time period, what it is to the mobile terminal isSystem sends the primary presetting message.
As a kind of optional embodiment, the preset time period is:2~4 seconds.
As a kind of optional embodiment, module 201 is monitored, is specifically used for:
Based on handle message processing facilities, the presetting message is sent to the system of the mobile terminal;Or by wideBroadcast mode sends the presetting message to the system of the mobile terminal.
As a kind of optional embodiment, the presetting message is null message.
The device for the disconnection reconnecting introduced by the present embodiment is the method for implementing the embodiment of the present application interrupt line reconnectionUsed device, so the method based on the disconnection reconnecting described in the embodiment of the present application, those skilled in the artThe specific implementation mode and its various change form of the device of the disconnection reconnecting of the present embodiment can be understood, thus herein forHow the device of the disconnection reconnecting realizes that the method in the embodiment of the present application is no longer discussed in detail.As long as the affiliated technology people in this fieldMember implements device used by the method for the embodiment of the present application interrupt line reconnection, belongs to the range to be protected of the application.
Technical solution in above-mentioned the embodiment of the present application, at least has the following technical effect that or advantage:
In the embodiment of the present application, a kind of device of disconnection reconnecting is disclosed, including:Module is monitored, in clientWith server networking process, the network state of mobile terminal is monitored, wherein the client is mounted on the movementIn the system of terminal, the monitoring module is arranged in the client;Occur in the network for finding the mobile terminal abnormalWhen, send a presetting message to the system of the mobile terminal;Reconnection module for receiving the presetting message, and is based on institutePresetting message is stated, the network connection between the client and the server is re-established, wherein the reconnection module settingIn the client.Due to when carrying out disconnection reconnecting, not depending on the broadcast message that cell phone system issues, therefore avoid placeReason logic causes confusion, and is reconnected twice without establishing, and then improve reconnection speed, alleviates system burden.So solutionIt has determined in the prior art when carrying out disconnection reconnecting, there are processing logical miss, and reconnection speed is slower, the skill of system burden weightArt problem is realized when carrying out disconnection reconnecting, handles clear logic, mitigates system burden, improves the technology of reconnection speedEffect.
Embodiment three
Based on same inventive concept, as shown in figure 3, present embodiments providing a kind of device 300 of disconnection reconnecting, including depositReservoir 310, processor 320 and it is stored in the computer program 311 that can be run on memory 310 and on the processor 320, handledDevice 320 realizes following steps when executing computer program 311:
In client and server networking process, monitors module and the network state of mobile terminal is monitored, whereinThe client is mounted in the system of the mobile terminal, and the monitoring module is arranged in the client;Finding instituteWhen the network for stating mobile terminal occurs abnormal, the monitoring module sends a presetting message to the system of the mobile terminal;WeightGang mould block receives the presetting message, and is based on the presetting message, re-establishes between the client and the serverNetwork connection, wherein the reconnection module is arranged in the client.
In specific implementation process, when processor 320 executes computer program 311, appointing in embodiment one may be implementedOne embodiment.
Example IV
Based on same inventive concept, as shown in figure 4, a kind of computer readable storage medium 400 is present embodiments provided,On be stored with computer program 411, computer program 411 realizes following steps when being executed by processor:
In client and server networking process, monitors module and the network state of mobile terminal is monitored, whereinThe client is mounted in the system of the mobile terminal, and the monitoring module is arranged in the client;Finding instituteWhen the network for stating mobile terminal occurs abnormal, the monitoring module sends a presetting message to the system of the mobile terminal;WeightGang mould block receives the presetting message, and is based on the presetting message, re-establishes between the client and the serverNetwork connection, wherein the reconnection module is arranged in the client.
In specific implementation process, when computer program 411 is executed by processor, any in embodiment one may be implementedEmbodiment.
It should be understood by those skilled in the art that, the embodiment of the present invention can be provided as method, system or computer programProduct.Therefore, complete hardware embodiment, complete software embodiment or reality combining software and hardware aspects can be used in the present inventionApply the form of example.Moreover, the present invention can be used in one or more wherein include computer usable program code computerThe computer program production implemented in usable storage medium (including but not limited to magnetic disk storage, CD-ROM, optical memory etc.)The form of product.
The present invention be with reference to according to the method for the embodiment of the present invention, the flow of equipment (system) and computer program productFigure and/or block diagram describe.It should be understood that can be realized by computer program instructions every first-class in flowchart and/or the block diagramThe combination of flow and/or box in journey and/or box and flowchart and/or the block diagram.These computer programs can be providedInstruct the processor of all-purpose computer, special purpose computer, Embedded Processor or other programmable data processing devices to produceA raw machine so that the instruction executed by computer or the processor of other programmable data processing devices is generated for realThe device for the function of being specified in present one flow of flow chart or one box of multiple flows and/or block diagram or multiple boxes.
These computer program instructions, which may also be stored in, can guide computer or other programmable data processing devices with spyDetermine in the computer-readable memory that mode works so that instruction generation stored in the computer readable memory includes referring toEnable the manufacture of device, the command device realize in one flow of flow chart or multiple flows and/or one box of block diagram orThe function of being specified in multiple boxes.
These computer program instructions also can be loaded onto a computer or other programmable data processing device so that countSeries of operation steps are executed on calculation machine or other programmable devices to generate computer implemented processing, in computer orThe instruction executed on other programmable devices is provided for realizing in one flow of flow chart or multiple flows and/or block diagram oneThe step of function of being specified in a box or multiple boxes.
Although preferred embodiments of the present invention have been described, it is created once a person skilled in the art knows basicProperty concept, then additional changes and modifications may be made to these embodiments.So it includes excellent that the following claims are intended to be interpreted asIt selects embodiment and falls into all change and modification of the scope of the invention.
Obviously, various changes and modifications can be made to the invention without departing from essence of the invention by those skilled in the artGod and range.In this way, if these modifications and changes of the present invention belongs to the range of the claims in the present invention and its equivalent technologiesWithin, then the present invention is also intended to include these modifications and variations.