CN104821939B - It is a kind of to be used to implement computer and the method and apparatus of mobile equipment room asynchronous communication - Google Patents

It is a kind of to be used to implement computer and the method and apparatus of mobile equipment room asynchronous communication Download PDF

Info

Publication number
CN104821939B
CN104821939B CN201510169424.5A CN201510169424A CN104821939B CN 104821939 B CN104821939 B CN 104821939B CN 201510169424 A CN201510169424 A CN 201510169424A CN 104821939 B CN104821939 B CN 104821939B
Authority
CN
China
Prior art keywords
mobile equipment
sent
information
network module
communication
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201510169424.5A
Other languages
Chinese (zh)
Other versions
CN104821939A (en
Inventor
蔡欢
杜冰
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Baidu Netcom Science and Technology Co Ltd
Original Assignee
Beijing Baidu Netcom Science and Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Baidu Netcom Science and Technology Co Ltd filed Critical Beijing Baidu Netcom Science and Technology Co Ltd
Priority to CN201510169424.5A priority Critical patent/CN104821939B/en
Publication of CN104821939A publication Critical patent/CN104821939A/en
Application granted granted Critical
Publication of CN104821939B publication Critical patent/CN104821939B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L69/00Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
    • H04L69/16Implementation or adaptation of Internet protocol [IP], of transmission control protocol [TCP] or of user datagram protocol [UDP]
    • H04L69/161Implementation details of TCP/IP or UDP/IP stack architecture; Specification of modified or new header fields
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L65/00Network arrangements, protocols or services for supporting real-time applications in data packet communication
    • H04L65/40Support for services or applications
    • H04L65/4061Push-to services, e.g. push-to-talk or push-to-video

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Multimedia (AREA)
  • Computer Security & Cryptography (AREA)
  • Mobile Radio Communication Systems (AREA)

Abstract

Computer and the method and apparatus of mobile equipment room asynchronous communication are used to implement the object of the present invention is to provide a kind of;Corresponding program in mobile equipment is called, to start the server of described program;By the server, the communication port with the mobile equipment room is created, and long connection is kept with the mobile equipment;Based on the long connection, by the communication port, by information asynchronous transmission to be sent to the mobile equipment.Compared with prior art, the present invention improves the robustness and stability of computer and mobile communication between devices, the collapse of entire mobile device end can't particularly be caused when data and huge number of request, improve the usage experience of user, also, such mode relieves the coupling of service logic and network layer.

Description

It is a kind of to be used to implement computer and the method and apparatus of mobile equipment room asynchronous communication
Technical field
The present invention relates to computer realm more particularly to a kind of computer that is used to implement with moving equipment room asynchronous communication Method and apparatus.
Background technology
Existing assistant's class product and the client with assistant's function, in the APP with mobile equipment itself When (Application, application program) is communicated, dependence be all official debugging bridge carry out data exchange.For example, with When the APP of Android mobile phone itself is communicated, ADB (Android Debug Bridge, the Android debugging of official of Google are relied on Bridge) and Android mobile phone ADBD carry out data exchange, no matter upper-layer protocol is HTTP (HTTP-Hypertext transfer Protocol, hypertext transfer protocol) or the progress of other agreements.It is equivalent to when request of data is initiated every time to movement Equipment end has done once short connection, when computer client is excessive to mobile device end connection request (such as in computer terminal The FTP (File Transfer Protocol, File Transfer Protocol) set up to mobile device end accesses), then directly As a result the entire ADBD of mobile device end can be caused abnormal, connection and data so as to cause entire computer and mobile equipment room Access goes wrong, also, has no idea to realize that the server built in mobile device end carries out message push to computer terminal.
Therefore, how to stablize, efficiently realize that computer with moving the communication of equipment room, becomes those skilled in the art urgently One of need to solve the problems, such as.
The content of the invention
Computer and the method and apparatus of mobile equipment room asynchronous communication are used to implement the object of the present invention is to provide a kind of.
According to an aspect of the invention, there is provided a kind of be used to implement computer and the side of mobile equipment room asynchronous communication Method, wherein, this method comprises the following steps:
Corresponding program in mobile equipment is called, to start the server of described program;
By the server, the communication port with the mobile equipment room is created, and keeps growing with the mobile equipment Connection;
Based on the long connection, by the communication port, by information asynchronous transmission to be sent to the mobile equipment.
According to another aspect of the present invention, additionally provide one kind and be used to implement computer and mobile equipment room asynchronous communication Device, wherein, which includes:
For calling corresponding program in mobile equipment, to start the device of the server of described program;
For by the server, creating the communication port with the mobile equipment room, and being protected with the mobile equipment Hold the device of long connection;
For being based on the long connection, by the communication port, information asynchronous transmission to be sent to the movement is set Standby device.
Compared with prior art, the present invention improves the robustness and stability of computer and mobile communication between devices, special It is not the collapse that can't cause entire mobile device end when data and huge number of request, improves the usage experience of user, Also, such mode relieves the coupling of service logic and network layer.
Further, arbitrary thread can call network module in the present invention, the operation without blocking original thread, i.e. The return that original thread waits result will not be allowed just to perform down, further improve computer and mobile communication between devices Efficiency and stability, improve the usage experience of user.
Further, mobile device end message such as deleting application, installation application, update application can push away in real time It is sent to computer terminal so that computer terminal is capable of the change of real-time synchronization display mobile device end, further improves user's Usage experience.
Description of the drawings
By reading the detailed description made to non-limiting example made with reference to the following drawings, of the invention is other Feature, objects and advantages will become more apparent upon:
Fig. 1 is that the structure for being used to implement computer and the device of mobile equipment room asynchronous communication of one aspect of the invention is shown It is intended to;
Fig. 2 is the flow of the method for being used to implement computer and mobile equipment room asynchronous communication of another aspect of the invention Schematic diagram.
The same or similar reference numeral represents the same or similar component in attached drawing.
Specific embodiment
It should be mentioned that some exemplary embodiments are described as before exemplary embodiment is discussed in greater detail The processing described as flow chart or method.Although operations are described as the processing of order by flow chart, therein to be permitted Multioperation can be implemented concurrently, concomitantly or simultaneously.In addition, the order of operations can be rearranged.When it The processing can be terminated when operation is completed, it is also possible to have the additional step being not included in attached drawing.The processing It can correspond to method, function, regulation, subroutine, subprogram etc..
Alleged within a context " computer equipment ", also referred to as " computer ", referring to can be by running preset program or referring to Make performing the intelligent electronic device of the predetermined process process such as numerical computations and/or logical calculated, can include processor with Memory, by the survival that prestores in memory of processor execution instruct to perform predetermined process process or by ASIC, The hardware such as FPGA, DSP perform predetermined process process or are realized by said two devices combination.Computer equipment includes but unlimited In server, PC, laptop, tablet computer, smart mobile phone etc..
The computer equipment includes user equipment and the network equipment.Wherein, the user equipment includes but not limited to electricity Brain, smart mobile phone, PDA etc.;The network equipment includes but not limited to single network server, multiple network servers form Server group or the cloud being made of a large amount of computers or network server based on cloud computing (Cloud Computing), wherein, Cloud computing is one kind of Distributed Calculation, a super virtual computer being made of the computer collection of a group loose couplings.Its In, the computer equipment can isolated operation realize the present invention, also can access network and by with other calculating in network The present invention is realized in the interactive operation of machine equipment.Wherein, the network residing for the computer equipment include but not limited to internet, Wide area network, Metropolitan Area Network (MAN), LAN, VPN network etc..
It should be noted that the user equipment, the network equipment and network etc. are only for example, other are existing or from now on may be used The computer equipment or network that can occur such as are applicable to the present invention, should also be included within the scope of the present invention, and to draw It is incorporated herein with mode.
Method (some of them are illustrated by flow) discussed hereafter can be by hardware, software, firmware, centre Part, microcode, hardware description language or its any combination are implemented.Implement when with software, firmware, middleware or microcode When, to implement the program code of necessary task or code segment can be stored in machine or computer-readable medium and (for example deposit Storage media) in.(one or more) processor can implement necessary task.
Concrete structure and function detail disclosed herein are only representative, and are for describing showing for the present invention The purpose of example property embodiment.But the present invention can be implemented by many alternative forms, and be not interpreted as It is limited only by the embodiments set forth herein.
Although it should be appreciated that may have been used term " first ", " second " etc. herein to describe unit, But these units should not be limited by these terms.The use of these items is only for by a unit and another unit It distinguishes.For example, in the case of the scope without departing substantially from exemplary embodiment, it is single that first module can be referred to as second Member, and similarly second unit can be referred to as first module.Term "and/or" used herein above include one of them or The arbitrary and all combination of more listed associated items.
It should be appreciated that when a unit is referred to as " connecting " or during " coupled " to another unit, can directly connect It connects or is coupled to another unit or there may be temporary location.In contrast, when a unit is referred to as " directly connecting Connect " or " direct-coupling " arrive another unit when, then there is no temporary locations.It should explain in a comparable manner and be used to retouch State the relation between unit other words (such as " between being in ... " compared to " between being directly in ... ", " and with ... it is adjacent Closely " compared to " with ... be directly adjacent to " etc.).
Term used herein above is not intended to limit exemplary embodiment just for the sake of description specific embodiment.Unless Context clearly refers else, otherwise singulative used herein above "one", " one " also attempt to include plural number.Should also When understanding, term " comprising " and/or "comprising" used herein above provide stated feature, integer, step, operation, The presence of unit and/or component, and do not preclude the presence or addition of other one or more features, integer, step, operation, unit, Component and/or its combination.
It should further be mentioned that in some replaces realization modes, the function/action being previously mentioned can be according to different from attached The order indicated in figure occurs.For example, depending on involved function/action, the two width figures shown in succession actually may be used Substantially simultaneously to perform or can perform in a reverse order sometimes.
The present invention is described in further detail below in conjunction with the accompanying drawings.
Fig. 1 is that the structure for being used to implement computer and the device of mobile equipment room asynchronous communication of one aspect of the invention is shown It is intended to.
This is used to implement computer and the device (hereinafter referred to as " asynchronous communication device 1 ") of mobile equipment room asynchronous communication wraps Include to call corresponding program in mobile equipment, to start the device (hereinafter referred to as " routine call of the server of described program Device 101 "), for passing through the server, create the communication port with the mobile equipment room, and with the mobile equipment The device (hereinafter referred to as " passage creating device 102 ") of long connection is kept and for being based on the long connection, by described logical Passage is believed, by the device (hereinafter referred to as " asynchronous transmission device 103 ") of information asynchronous transmission to be sent to the mobile equipment.
Wherein, program loading system 101 calls corresponding program in mobile equipment, to start the server of described program.
Specifically, program loading system 101 is by the interaction with corresponding mobile equipment, such as passes through one or many tune With debug instruments or the mode of other agreements, corresponding program in the movement equipment is called, to start the service of described program Device.
For example, program loading system 101 is by debug instruments, such as ADB, (Android Debug Bridge, Android are debugged Bridge), the program in corresponding mobile equipment is had invoked, and server self-built in the program is started, it is e.g., self-built in the program Mina servers.
It should be noted that the above-mentioned examples are merely illustrative of the technical solutions of the present invention rather than the limit to the present invention System, it should be appreciated by those skilled in the art that any other it is existing or be likely to occur from now on calling movement equipment in it is corresponding Program is such as applicable to the present invention, should also be included in the scope of the present invention to start the realization method of the server of the program Within, and be incorporated herein by reference herein.
Here, the mobile equipment includes but not limited to mobile phone, smart mobile phone, tablet computer etc..
It should be noted that the mobile equipment is only for example, other mobile equipment that are existing or being likely to occur from now on The present invention is such as applicable to, should also be included within the scope of the present invention, and is incorporated herein by reference.
Here, corresponding program is corresponding with the asynchronous communication device 1 in the mobile equipment, for it is described asynchronous Communicator 1 combines, and manages the mobile equipment, such as all kinds of mobile phone assistants together.
Here, the server of described program is a web application frame, it is used to help developer and simply develops The web application of high-performance and enhanced scalability.The server is such as mina servers, Netty servers.Here, Mina servers provide one by Java NIO in different transmission, such as TCP/IP and UDP/IP, upper abstract event The asynchronous API of driving.Here, Netty servers provide asynchronous, event driven web application frame and instrument, use Quickly to develop the network server of high-performance, high reliability and client-side program.
It should be noted that the server of corresponding program and the program is only for example in the mobile equipment, other are existing The server of corresponding program and the program is such as applicable to the present invention in mobile equipment that is having or being likely to occur from now on, also should Within the scope of the present invention, and it is incorporated herein by reference.
Passage creating device 102 creates the communication port with the mobile equipment room by the server, and with it is described Mobile equipment keeps long connection.
Specifically, corresponding program in mobile equipment is called in program loading system 101, to start the server of the program Afterwards, passage creating device 102 establishes the local between the computer corresponding to the asynchronous communication device 1 and the movement equipment Net, so as to establish the long connection between the computer and the movement equipment, such as TCP (Transmission Control Protocol, transmission control protocol) length connection, also, the passage creating device 102 passes through corresponding program in the movement equipment Server, create with the communication port of the movement equipment room, such as TCP Channel (TCP channel).
For example, when mobile equipment is by USB data line, WiFi etc., when being connected to computer, mobile equipment causes computer USB data line can be identified by or WiFi is connected to the movement equipment of computer, and between computer and mobile equipment A LAN only comprising the computer with mobile equipment is established, after which establishes, mobile equipment informs computer Its IP address, then the passage creating device 102 on the asynchronous communication device 1 in computer be based on the IP address, set to the movement Preparation send TCP long connections to establish request.Server in mobile equipment, such as foregoing mina servers are being received from calculating After request is established in the long connection of machine, according to establishing TCP long connections between Transmission Control Protocol and computer.Also, the passage creating device 102, such as the scheduler (dispatcher) in the asynchronous communication device 1, the communication port with the movement equipment room is created, and be somebody's turn to do The server of corresponding program also correspondingly creates a socket interface channel in mobile equipment, and two passages are connected to each other, i.e., The communication port of the computer and the movement equipment room is formed, such as TCP Channel.
Here, the passage to communicate that the communication port is established for computer with mobile equipment room, for computer The mutual biography of data is carried out with mobile equipment.
It should be noted that the above-mentioned examples are merely illustrative of the technical solutions of the present invention rather than the limit to the present invention System, it should be appreciated by those skilled in the art that any other existing or establishment for being likely to occur from now on and mobile equipment room is logical Believe passage and keep the long realization method connected therewith, be such as applicable to the present invention, should also be included in the scope of the present invention with It is interior, and be incorporated herein by reference herein.
Asynchronous transmission device 103 be based on it is described it is long connect, by the communication port, by information asynchronous transmission to be sent extremely The mobile equipment.
Specifically, the length with the movement equipment room that asynchronous transmission device 103 is kept based on the passage creating device 102 Connection passes through the communication port of its establishment, such as TCP channel, by information asynchronous transmission to be sent to the movement equipment.
Here, all transmission are based on event-driven, for example, asynchronous communication device 1 is in the state waited, when movement is set During for having corresponding message to need to be transferred to the computer, which carries out reading event, to disappear to what is received Breath is parsed;When computer have for message need to be transferred to the movement equipment when, the asynchronous communication device 1 is into row write Event, by the message asynchronous transmission to the movement equipment.Therefore, can achieve the purpose that not block interface operation, also, will The realization of network layer and the logic of operation layer are completely separable, and unique interaction is exactly interface and readjustment.
It should be noted that the above-mentioned examples are merely illustrative of the technical solutions of the present invention rather than the limit to the present invention System, it should be appreciated by those skilled in the art that any other asynchronous transmission information to movement that is existing or being likely to occur from now on is set Standby realization method, is such as applicable to the present invention, should also be included within the scope of the present invention, and wraps by reference herein It is contained in this.
Here, asynchronous communication device 1 calls corresponding program in mobile equipment, to start the server of described program;It is logical The server is crossed, the communication port with the mobile equipment room is created, and long connection is kept with the mobile equipment;Based on institute Long connection is stated, by the communication port, by information asynchronous transmission to be sent to the mobile equipment, improves computer with moving The robustness and stability of dynamic communication between devices, can't particularly cause entirely to move equipment when data and huge number of request The collapse at end improves the usage experience of user, also, such mode relieves the coupling of service logic and network layer.
Preferably, which further includes to initialize the device (hereinafter referred to as " initialization of network module Device 104 ", not shown) and for the device of sender and recipient to be respectively created in the network module (hereinafter referred to as " module creation device 105 ", not shown), wherein, when the network module is called, the sender sends out communication event It send to the recipient, the recipient parses the communication event, to determine the information to be sent.
Specifically, apparatus for initializing 104 initializes network module, for example, needed for the apparatus for initializing 104 initialization network Environment.Then, sender (Sender) and recipient is respectively created in module creation device 105 in the network module (Receiver).When the network module is called, the sender will be sent to the corresponding communication event of the calling The recipient, the recipient parse the communication event, to determine to be sent to the to be sent of the movement equipment Information.Then, the scheduler or be sent to foregoing asynchronous which is sent to the information to be sent in the network module Sending device 103, so that it is based on the long connection with mobile equipment room, it is by the communication port, such as TCP channel, this is pending Breath of delivering letters is sent to the movement equipment.
It is highly preferred that the network module can be called by arbitrary thread.
Here, arbitrary thread can call the network module, the operation without blocking original thread, i.e. will not allow original Thread the return of result is waited just to perform down, further improve the efficiency of computer and mobile communication between devices with it is steady It is qualitative, improve the usage experience of user.
Preferably, which further includes for when there is request at interface, will be with the corresponding communication of the request Event is sent to the device (hereinafter referred to as " event sending device 106 ", not shown) of the scheduler of the network module, wherein, The scheduler obtains information to be sent determined by the recipient, different by the communication port based on the long connection Step is sent to the mobile equipment.
Specifically, when there is request at interface, communication event corresponding with the request is sent to this by event sending device 106 The scheduler (dispatcher) of network module.For example, caller A is needed message B to be sent being sent to corresponding movement and set It is standby, therefore, request is had submitted on interface, event sending device 106 is according to the request, it is determined that corresponding communication thing Part, and the communication event has been sent to the scheduler of the network module.Recipient in the network module is to the communication event It is parsed, determines to be sent to the information to be sent of mobile equipment, and the information to be sent is sent to the scheduler, the tune Degree device obtains the information to be sent;And then the scheduler kept based on passage creating device 102 with the movement equipment room Long connection, by the communication port, by the information asynchronous transmission to be sent to the movement equipment.
Preferably, the scheduler is the passage creating device 102, i.e. the scheduler creates and the mobile equipment Between communication port, and keep long connection with the mobile equipment.The scheduler obtain the recipient parse it is definite pending It send to the information to be sent of mobile equipment, by the communication port that it is created with mobile equipment room, such as TCP channel treats this Information asynchronous transmission is sent to the movement equipment.
Preferably, wherein, which further includes to distribute corresponding ID number for the information to be sent It is device (hereinafter referred to as " ID distributors 107 ", not shown), described pending based on what is received for receiving the mobile equipment The device for the feedback information that breath of delivering letters is returned, wherein, it is (hereinafter referred to as " anti-that the feedback information includes the corresponding ID number Reception device 108 " is presented, not shown) and for the ID number according to the feedback information, determine corresponding registered callbacks Caller device (hereinafter referred to as " call determining device 109 ", not shown).
Specifically, ID distributors 107 are the corresponding ID number of information to be sent distribution for being sent to mobile equipment, In, which carries out also having mapping relations between unique mark, and the caller of registered callbacks to the information to be sent.It is different It walks sending device 103 and is based on the long connection, it is by the communication port, the information to be sent with corresponding ID number is asynchronous It is sent to the mobile equipment.
Mobile equipment receives the information for carrying ID number, and the information is carried out successively filtering in filtering chain and is unpacked, And then it is in operation layer that all information processings are complete, and back transfer is carried out, finally, form one and equally carry the ID number Feedback information, and it is back to the asynchronous communication device 1.Feedback reception device 108 in the asynchronous communication device 1 receives the movement The feedback information that equipment is returned based on the information to be sent received, wherein, which includes corresponding ID number.
Then, call determining device 109 according to the ID number for changing feedback information and its carrying, by matching inquiry, determine with The caller of the corresponding registered callbacks of the ID number, and then, which is fed back into the caller.
It should be noted that the above-mentioned examples are merely illustrative of the technical solutions of the present invention rather than the limit to the present invention System, it should be appreciated by those skilled in the art that any other caller of definite registered callbacks that is existing or being likely to occur from now on Realization method, be such as applicable to the present invention, should also be included within the scope of the present invention, and include by reference herein In this.
Preferably, which further includes, based on the long connection, to pass through the communication channel, receive Device (hereinafter referred to as " update reception device 110 ", not shown) using fresh information that the mobile equipment is pushed and For the application fresh information to be distributed to corresponding caller, with the device synchronous with the mobile equipment (hereinafter referred to as " update diostribution device 111 ", not shown).
Specifically, when the application program in mobile equipment has corresponding application fresh information, using the biography of agreement Defeated agreement, such as Transmission Control Protocol are pushed to corresponding computer, for example, the movement equipment maintained with the computer it is foregoing Long connection, have in the movement equipment and be based on length connection using the application program of fresh information, by aforementioned communication channel, This is pushed using fresh information to the computer;The update reception device 110 is connected based on the length, by the communication channel, is connect Receive the application fresh information that the movement equipment is pushed.Here, this for example carries corresponding CMD orders using fresh information Number.Diostribution device 111 is updated according to the CMD command numbers, is searched, determines to register the calling that this is needed to apply fresh information This is distributed to identified caller by person, then, the update diostribution device 111 using fresh information, so that the calculating Machine is synchronous with the movement equipment.
Here, mobile device end message such as deleting application, installation application, update application can be pushed to meter in real time Calculate generator terminal so that computer terminal is capable of the change of real-time synchronization display mobile device end, and further improve user uses body It tests.
Fig. 2 is the flow of the method for being used to implement computer and mobile equipment room asynchronous communication of another aspect of the invention Schematic diagram.
In step s 201, asynchronous communication device 1 calls corresponding program in mobile equipment, to start the clothes of described program Business device.
Specifically, in step s 201, asynchronous communication device 1 is by the interaction with corresponding mobile equipment, such as passes through One or many modes for calling debug instruments or other agreements, call corresponding program in the movement equipment, with described in startup The server of program.
For example, in step s 201, asynchronous communication device 1 is by debug instruments, such as ADB (Android Debug Bridge, Android debugging bridge), the program in corresponding mobile equipment is had invoked, and server self-built in the program is started, Such as, mina servers self-built in the program.
It should be noted that the above-mentioned examples are merely illustrative of the technical solutions of the present invention rather than the limit to the present invention System, it should be appreciated by those skilled in the art that any other it is existing or be likely to occur from now on calling movement equipment in it is corresponding Program is such as applicable to the present invention, should also be included in the scope of the present invention to start the realization method of the server of the program Within, and be incorporated herein by reference herein.
Here, the mobile equipment includes but not limited to mobile phone, smart mobile phone, tablet computer etc..
It should be noted that the mobile equipment is only for example, other mobile equipment that are existing or being likely to occur from now on The present invention is such as applicable to, should also be included within the scope of the present invention, and is incorporated herein by reference.
Here, corresponding program is corresponding with the asynchronous communication device 1 in the mobile equipment, for it is described asynchronous Communicator 1 combines, and manages the mobile equipment, such as all kinds of mobile phone assistants together.
Here, the server of described program is a web application frame, it is used to help developer and simply develops The web application of high-performance and enhanced scalability.The server is such as mina servers, Netty servers.Here, Mina servers provide one by Java NIO in different transmission, such as TCP/IP and UDP/IP, upper abstract event The asynchronous API of driving.Here, Netty servers provide asynchronous, event driven web application frame and instrument, use Quickly to develop the network server of high-performance, high reliability and client-side program.
It should be noted that the server of corresponding program and the program is only for example in the mobile equipment, other are existing The server of corresponding program and the program is such as applicable to the present invention in mobile equipment that is having or being likely to occur from now on, also should Within the scope of the present invention, and it is incorporated herein by reference.
In step S202, asynchronous communication device 1 is created the communication with the mobile equipment room and is led to by the server Road, and keep long connection with the mobile equipment.
Specifically, corresponding program in mobile equipment is called in step s 201 in asynchronous communication device 1, to start the journey After the server of sequence, in step S202, asynchronous communication device 1 establish computer corresponding to the asynchronous communication device 1 with LAN between the movement equipment, so as to establish the long connection between the computer and the movement equipment, such as TCP (Transmission Control Protocol, transmission control protocol) long connection, also, in step S202, asynchronous communication Device 1 creates the communication port with the movement equipment room, such as TCP by the server of corresponding program in the movement equipment Channel (TCP channel).
For example, when mobile equipment is by USB data line, WiFi etc., when being connected to computer, mobile equipment causes computer USB data line can be identified by or WiFi is connected to the movement equipment of computer, and between computer and mobile equipment A LAN only comprising the computer with mobile equipment is established, after which establishes, mobile equipment informs computer Its IP address, then in step S202, asynchronous communication device 1 is based on the IP address, and sending TCP long connections to the movement equipment builds Vertical request.Server in mobile equipment, such as foregoing mina servers establish request receiving the long connection from computer Afterwards, according to establishing TCP long connections between Transmission Control Protocol and computer.Also, in step S202, asynchronous communication device 1 or such as Scheduler (dispatcher) thereon, establishment and the communication port of the movement equipment room, and corresponding journey in the movement equipment The server of sequence also correspondingly creates a socket interface channel, and two passages are connected to each other, that is, form the computer and the shifting The communication port of dynamic equipment room, such as TCP Channel.
Here, the passage to communicate that the communication port is established for computer with mobile equipment room, for computer The mutual biography of data is carried out with mobile equipment.
It should be noted that the above-mentioned examples are merely illustrative of the technical solutions of the present invention rather than the limit to the present invention System, it should be appreciated by those skilled in the art that any other existing or establishment for being likely to occur from now on and mobile equipment room is logical Believe passage and keep the long realization method connected therewith, be such as applicable to the present invention, should also be included in the scope of the present invention with It is interior, and be incorporated herein by reference herein.
In step S203, asynchronous communication device 1 is based on the long connection, by the communication port, delivers letters pending Asynchronous transmission is ceased to the mobile equipment.
Specifically, in step S203, asynchronous communication device 1 based on retained in step S202 with the movement equipment Between long connection, pass through its communication port created, such as TCP channel, by information asynchronous transmission to be sent to the movement equipment.
Here, all transmission are based on event-driven, for example, asynchronous communication device 1 is in the state waited, when movement is set During for having corresponding message to need to be transferred to the computer, which carries out reading event, to disappear to what is received Breath is parsed;When computer have for message need to be transferred to the movement equipment when, the asynchronous communication device 1 is into row write Event, by the message asynchronous transmission to the movement equipment.Therefore, can achieve the purpose that not block interface operation, also, will The realization of network layer and the logic of operation layer are completely separable, and unique interaction is exactly interface and readjustment.
It should be noted that the above-mentioned examples are merely illustrative of the technical solutions of the present invention rather than the limit to the present invention System, it should be appreciated by those skilled in the art that any other asynchronous transmission information to movement that is existing or being likely to occur from now on is set Standby realization method, is such as applicable to the present invention, should also be included within the scope of the present invention, and wraps by reference herein It is contained in this.
Here, asynchronous communication device 1 calls corresponding program in mobile equipment, to start the server of described program;It is logical The server is crossed, the communication port with the mobile equipment room is created, and long connection is kept with the mobile equipment;Based on institute Long connection is stated, by the communication port, by information asynchronous transmission to be sent to the mobile equipment, improves computer with moving The robustness and stability of dynamic communication between devices, can't particularly cause entirely to move equipment when data and huge number of request The collapse at end improves the usage experience of user, also, such mode relieves the coupling of service logic and network layer.
Preferably, this method further include initialization network module the step of (hereinafter referred to as " step S204 ", not shown) with And the step of sender and recipient are respectively created in the network module (hereinafter referred to as " step S205 ", not shown), In, when the network module is called, communication event is sent to the recipient by the sender, and the recipient is to institute It states communication event to be parsed, to determine the information to be sent.
Specifically, in step S204, asynchronous communication device 1 initializes network module, for example, in step S204, it is different It walks communicator 1 and initializes environment needed for network.Then, in step S205, asynchronous communication device 1 is in the network module Sender (Sender) and recipient (Receiver) is respectively created.When the network module is called, the sender will The recipient is sent to the corresponding communication event of the calling, the recipient parses the communication event, with Determine to be sent to the information to be sent of the movement equipment.Then, which it is asynchronous logical by the information to be sent to be sent to this T unit 1 or further, the scheduler being sent in the network module, so that it with the long of mobile equipment room based on connecting It connects, by the communication port, such as TCP channel, which is sent to the movement equipment.
It is highly preferred that the network module can be called by arbitrary thread.
Here, arbitrary thread can call the network module, the operation without blocking original thread, i.e. will not allow original Thread the return of result is waited just to perform down, further improve the efficiency of computer and mobile communication between devices with it is steady It is qualitative, improve the usage experience of user.
Preferably, this method is further included when there is request at interface, will be sent to institute with the corresponding communication event of the request The step of stating the scheduler of network module (hereinafter referred to as " step S206 ", not shown), wherein, it is connect described in the scheduler acquisition Information to be sent determined by receipts person, based on the long connection, by the communication port, asynchronous transmission to the movement is set It is standby.
Specifically, when there is request at interface, in step S206, asynchronous communication device 1 will communication corresponding with the request Event is sent to the scheduler (dispatcher) of the network module.For example, caller A needs message B to be sent being sent to Therefore corresponding mobile equipment, has submitted request on interface, in step S206, asynchronous communication device 1 please according to this It asks, it is determined that corresponding communication event, and the communication event has been sent to the scheduler of the network module.The network mould Recipient in the block parses the communication event, determines to be sent to the information to be sent of mobile equipment, and this is pending Breath of delivering letters is sent to the scheduler, which obtains the information to be sent;And then the scheduler is based in step S202, What asynchronous communication device 1 was kept connects with the long of the movement equipment room, by the communication port, the information to be sent is asynchronous It is sent to the movement equipment.
Preferably, the scheduler created in step S202 with the communication port of the mobile equipment room, and with institute It states mobile equipment and keeps long connection.The scheduler, which obtains the recipient and parses, definite is sent to the to be sent of mobile equipment Information, by the communication port that it is created with mobile equipment room, which extremely should by such as TCP channel Mobile equipment.
Preferably, wherein, which further includes the step of distributing corresponding ID number for the information to be sent (hereinafter referred to as " step S207 ", not shown), the reception mobile equipment are returned based on the information to be sent received Feedback information the step of, wherein, the feedback information includes the corresponding ID number, and (hereinafter referred to as " step S208 ", figure is not Show) and ID number according to the feedback information, the step of determining the caller of corresponding registered callbacks, is (hereinafter referred to as " step S209 ", not shown).
Specifically, in step S207, asynchronous communication device 1 is the information to be sent distribution pair for being sent to mobile equipment The ID number answered, wherein, which to the information to be sent between unique mark, and the caller of registered callbacks also have Mapping relations.In step S203, asynchronous communication device 1 be based on it is described it is long connect, by the communication port, this is had pair The information asynchronous transmission to be sent of ID number is answered to the mobile equipment.
Mobile equipment receives the information for carrying ID number, and the information is carried out successively filtering in filtering chain and is unpacked, And then it is in operation layer that all information processings are complete, and back transfer is carried out, finally, form one and equally carry the ID number Feedback information, and it is back to the asynchronous communication device 1.In step S208, asynchronous communication device 1 receives the movement equipment and is based on The feedback information that the information to be sent received is returned, wherein, which includes corresponding ID number.
Then, in step S209, asynchronous communication device 1 passes through matching according to the ID number for changing feedback information and its carrying Inquiry determines the caller of registered callbacks corresponding with the ID number, and then, which is fed back into the caller.
It should be noted that the above-mentioned examples are merely illustrative of the technical solutions of the present invention rather than the limit to the present invention System, it should be appreciated by those skilled in the art that any other caller of definite registered callbacks that is existing or being likely to occur from now on Realization method, be such as applicable to the present invention, should also be included within the scope of the present invention, and include by reference herein In this.
Preferably, this method is further included based on the long connection, by the communication channel, receives the mobile equipment institute The step of application fresh information of push (hereinafter referred to as " step S210 ", not shown) and by the application fresh information point Corresponding caller is issued, with the step (hereinafter referred to as " step S211 ", not shown) synchronous with the mobile equipment.
Specifically, when the application program in mobile equipment has corresponding application fresh information, using the biography of agreement Defeated agreement, such as Transmission Control Protocol are pushed to corresponding computer, for example, the movement equipment maintained with the computer it is foregoing Long connection, have in the movement equipment and be based on length connection using the application program of fresh information, by aforementioned communication channel, This is pushed using fresh information to the computer;In step S210, asynchronous communication device 1 is connected based on the length, logical by this Believe channel, receive the application fresh information that the movement equipment is pushed.Here, this for example carried using fresh information it is corresponding CMD command numbers.In step S211, asynchronous communication device 1 is searched, determining to register needs to be somebody's turn to do according to the CMD command numbers Using the caller of fresh information, then, in step S211, this is distributed to institute by asynchronous communication device 1 using fresh information Definite caller, so that the computer is synchronous with the movement equipment.
Here, mobile device end message such as deleting application, installation application, update application can be pushed to meter in real time Calculate generator terminal so that computer terminal is capable of the change of real-time synchronization display mobile device end, and further improve user uses body It tests.
It should be noted that the present invention can be carried out in the assembly of software and/or software and hardware, for example, this hair Application-specific integrated circuit (ASIC) can be used in bright each device or any other is realized similar to hardware device.In one embodiment In, software program of the invention can perform to realize steps described above or function by processor.Similarly, it is of the invention Software program can be stored in computer readable recording medium storing program for performing (including relevant data structure), for example, RAM memory, Magnetic or optical driver or floppy disc and similar devices.In addition, hardware can be used to realize in some steps or function of the present invention, example Such as, as the circuit for coordinating to perform each step or function with processor.
It is obvious to a person skilled in the art that the invention is not restricted to the details of above-mentioned exemplary embodiment, Er Qie In the case of without departing substantially from spirit or essential attributes of the invention, the present invention can be realized in other specific forms.Therefore, no matter From the point of view of which point, the present embodiments are to be considered as illustrative and not restrictive, and the scope of the present invention is by appended power Profit requirement rather than above description limit, it is intended that all by what is fallen within the meaning and scope of the equivalent requirements of the claims Variation includes within the present invention.Any reference numeral in claim should not be considered as to the involved claim of limitation.This Outside, it is clear that one word of " comprising " is not excluded for other units or step, and odd number is not excluded for plural number.That is stated in system claims is multiple Unit or device can also be realized by a unit or device by software or hardware.The first, the second grade words are used for table Show title, and do not represent any particular order.

Claims (10)

1. a kind of be used to implement computer and the method for mobile equipment room asynchronous communication, wherein, this method comprises the following steps:
Corresponding program in mobile equipment is called, to start the server of described program;
Initialize the network module in the computer;
Sender and recipient is respectively created in the network module, wherein, when the network module is called, the hair Communication event is sent to the recipient by the person of sending, and the recipient parses the communication event, to be sent to determine Information;
By the server, the communication port with the mobile equipment room is created, and long connection is kept with the mobile equipment;
Based on the long connection, by the communication port, by the information asynchronous transmission to be sent to the mobile equipment.
It 2.,, will be described pending by the communication port based on the long connection according to the method described in claim 1, wherein Breath asynchronous transmission to the step of mobile equipment of delivering letters, includes:
When there is request at interface, the scheduler of the network module will be sent to the corresponding communication event of the request, wherein, The scheduler obtains information to be sent determined by the recipient, different by the communication port based on the long connection Step is sent to the mobile equipment.
3. method according to claim 1 or 2, wherein, the network module can be called by arbitrary thread.
4. according to the method described in claim 1, wherein, this method further includes:
Corresponding ID number is distributed for the information to be sent;
The feedback information that the mobile equipment is returned based on the information to be sent received is received, wherein, the feedback Information includes the corresponding ID number;
According to the ID number of the feedback information, the caller of the calling network module of corresponding registered callbacks is determined.
5. according to the method described in claim 1, wherein, this method further includes:
Based on the long connection, by the communication channel, the application fresh information that the mobile equipment is pushed is received;
The corresponding caller for calling the network module is distributed to using fresh information by described, with same with the mobile equipment Step.
6. a kind of be used to implement computer and the device of mobile equipment room asynchronous communication, wherein, which includes:
For calling corresponding program in mobile equipment, to start the device of the server of described program;
For initializing the device of the network module in the computer;
For the device of sender and recipient to be respectively created in the network module, wherein, when the network module is adjusted Communication event is sent to the recipient by used time, the sender, and the recipient parses the communication event, with Determine information to be sent;
For by the server, creating the communication port with the mobile equipment room, and keeping growing with the mobile equipment The device of connection;
For being based on the long connection, by the communication port, the information asynchronous transmission to be sent to the movement is set Standby device.
7. device according to claim 6, wherein, which further includes:
For when there is request at interface, the scheduler of the network module will to be sent to the corresponding communication event of the request Device, wherein, the scheduler obtains information to be sent determined by the recipient, based on the long connection, by described Communication port, asynchronous transmission to the mobile equipment.
8. the device according to claim 6 or 7, wherein, the network module can be called by arbitrary thread.
9. device according to claim 6, wherein, which further includes:
For distributing the device of corresponding ID number for the information to be sent;
For receiving the device for the feedback information that the mobile equipment is returned based on the information to be sent received, In, the feedback information includes the corresponding ID number;
For the ID number according to the feedback information, the calling of the calling network module of corresponding registered callbacks is determined The device of person.
10. device according to claim 6, wherein, which further includes:
For being based on the long connection, by the communication channel, the application fresh information that the mobile equipment is pushed is received Device;
For being distributed to the corresponding caller for calling the network module using fresh information by described, to be set with the movement Standby synchronous device.
CN201510169424.5A 2015-04-10 2015-04-10 It is a kind of to be used to implement computer and the method and apparatus of mobile equipment room asynchronous communication Active CN104821939B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201510169424.5A CN104821939B (en) 2015-04-10 2015-04-10 It is a kind of to be used to implement computer and the method and apparatus of mobile equipment room asynchronous communication

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201510169424.5A CN104821939B (en) 2015-04-10 2015-04-10 It is a kind of to be used to implement computer and the method and apparatus of mobile equipment room asynchronous communication

Publications (2)

Publication Number Publication Date
CN104821939A CN104821939A (en) 2015-08-05
CN104821939B true CN104821939B (en) 2018-06-05

Family

ID=53732102

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201510169424.5A Active CN104821939B (en) 2015-04-10 2015-04-10 It is a kind of to be used to implement computer and the method and apparatus of mobile equipment room asynchronous communication

Country Status (1)

Country Link
CN (1) CN104821939B (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105868109B (en) * 2016-03-28 2019-03-05 北京奇虎科技有限公司 A kind of improved mobile terminal application testing method and system
CN107483575A (en) * 2017-08-10 2017-12-15 安徽声讯信息技术有限公司 One kind is based on ADB and socket language and characters synchronizing information control systems and its method
CN108984614B (en) * 2018-06-12 2022-01-25 成都三零凯天通信实业有限公司 Visual image rapid identification method based on big data environment

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102123158A (en) * 2011-04-11 2011-07-13 深圳市同洲软件有限公司 Method and system for realizing network data processing
CN103731802A (en) * 2012-10-12 2014-04-16 上海宝信软件股份有限公司 Device management method based on Android mobile terminal

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102123158A (en) * 2011-04-11 2011-07-13 深圳市同洲软件有限公司 Method and system for realizing network data processing
CN103731802A (en) * 2012-10-12 2014-04-16 上海宝信软件股份有限公司 Device management method based on Android mobile terminal

Non-Patent Citations (3)

* Cited by examiner, † Cited by third party
Title
《Apache MINA 2.0 用户指南》第二章:基础知识;Defonds;《CSDN.NET/博客频道/Defonds的专栏》;20140108;第1-19页 *
Galaxy S4如何连接91助手?;samsung;《www.samsung.com》;20131211;第1,5-6页 *
基于Apache Mina实现的TCP长连接和短连接实例;peterwanghao;《CSDN.NET/博客频道/王浩的专栏》;20111024;第2页2.2处理流程,系统构架图,第3-5页 *

Also Published As

Publication number Publication date
CN104821939A (en) 2015-08-05

Similar Documents

Publication Publication Date Title
CN103942225A (en) Method and system for invoking resources of Hybrid App client and client
CN105487881A (en) Software installation package packaging method, device and system
CN104735108A (en) Method and device for using cloud desktops and cloud desktop system
CN106598692A (en) Method for creating mirror image file in logical volume and starting virtual machine, and server
CN108196787A (en) The quota management method and cluster storage system of cluster storage system
CN104821939B (en) It is a kind of to be used to implement computer and the method and apparatus of mobile equipment room asynchronous communication
CN109873839A (en) Method, server and the distributed system of data access
US20240146650A1 (en) Creating endpoints
Lee A framework for seamless execution of mobile applications in the cloud
CN110286981A (en) The display methods and display system of the use state of virtual cloud desktop server
CN105897865A (en) Protocol-independent network file service management system and method
CN109218447A (en) Media file distribution method and file distributing platform
CN109327555A (en) Distributed hair system, method and device
CN105119944B (en) Application starting method and related device
CN115361382B (en) Data processing method, device, equipment and storage medium based on data group
CN112073488A (en) Method and device for processing request
CN104570967A (en) Android system based remote control method and system
CN115378937B (en) Distributed concurrency method, device, equipment and readable storage medium for tasks
CN103220327B (en) user information storage method and device
CN103440134A (en) Webkit kernel-based storage resource service local extension method
CN102843424B (en) A kind of heterogeneous distributed cloud computing system and method
CN110187385A (en) Seismic data acquisition method, seismic data processing technique and device
CN110941735B (en) Directed graph-based path searching method and system, medium and computer system
CN115037572B (en) Application request identification method and device
CN110909007B (en) Data synchronization method, data synchronization device and storage medium

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
EXSB Decision made by sipo to initiate substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant