The method, apparatus and terminal of network connection
Technical field
The present invention relates to field of mobile communication, more particularly to the method, apparatus and terminal of a kind of network connection.
Background technique
Currently, point-to-point communication frame between a kind of equipment based on C/S framework, terminal node is provided that service, then
A service name is registered, and is declared away.If service can be searched by service name as client, and
Specified function is completed by far call or signal.When the title declared with server-side of title that client is searched matches,
Then client can establish session connection with server-side.Both sides can obtain the attribute information of established session, and in session basis
Realize data interaction.
A kind of intelligent home network based on above-mentioned communications framework, household equipment (SN) are connected to gateway, and gateway is connected to
Cloud platform (Cloud) realizes the interaction of cloud platform and home network.Household equipment/mobile device is all to support the communications framework
Terminal.The application program of the above-mentioned communications framework of gateway operation support is provided as the agency of cloud platform towards equipment in family
Cloud platform service.Equipment can establish therewith session connection by finding the cloud platform agency service of gateway in family, to pass through
The agency accesses cloud platform, realizes the data interaction with cloud platform.
Cloud platform rear end runs identical agency service application program, and the equipment other than home network is allowed to pass through 3G/4G/
WiFi remotely connects cloud platform service.The cloud platform agency service run in the agency service of cloud platform rear end and gateway provides phase
Therefore for the client-side program of equipment operation, two services cannot be distinguished in service layer in same service name.?
After equipment establishes session connection with the agency service of cloud platform rear end, if getting a surname that the service of gateway cloud platform issues
It accuses, then will be considered that and have built up session and directly ignore.Therefore, after underlying services switch, terminal is facing while having
When a variety of connection types reach same service, upper layer communication frame cannot be switched to by established session has more excellent connection steady
Qualitative and safety session connection.
Summary of the invention
The technical problem to be solved in the present invention is to provide a kind of method, apparatus of network connection and terminals, existing to solve
The problem for having technical network connective stability low.
In order to solve the above technical problems, on the one hand, the present invention provides a kind of method of network connection, comprising:
The current sessions connection type that detection conversates with current cloud platform agency service is in the network being presently in
It is whether optimal;
When current sessions connection type is not optimal, cloud platform agency service corresponding with optimal session connection type
Session is established, cloud platform is accessed by the optimal corresponding cloud platform agency service of session connection type.
Further, the session connection type includes that remote session connection is connected with local session;
Wherein, the session connection type that the cloud platform agency service provided with cloud platform access point conversates is long-range meeting
Words connection;
The session connection type that the cloud platform agency service provided with the local gateway of any type conversates is this
Ground session connection.
Further, the current sessions connection type to conversate with current cloud platform agency service is detected in locating network
In it is whether optimal, specifically include:
Obtain all session connection types that can be conversated with terminal;
The session attribute to conversate with current cloud platform agency service is extracted, current sessions connection type is obtained;
According to default session connection type priority grade, judge that current sessions connection type is in all session connection types
It is no optimal.
Further, the connection expense and/or stability when the session connection type priority grade is according to session are default.
Further, the method also includes:
Obtain the bottom communication connection type to conversate with current cloud platform agency service;
When bottom communication connection type changes, starts detection and work as with what current cloud platform agency service conversated
Whether preceding session connection type is optimal in the network being presently in.
On the other hand, the present invention also provides a kind of devices of network connection, comprising:
Detection module, for detecting the current sessions connection type to conversate with current cloud platform agency service current
It is whether optimal in locating network, and link block is sent to for will test result;
Link block, testing result for sending in detection module is current sessions connection type when being not optimal, with
The corresponding cloud platform agency service of optimal session connection type establishes session, passes through the optimal corresponding cloud of session connection type
Platform agent service access cloud platform.
Further, the session connection type includes that remote session connection is connected with local session;
Wherein, the session connection type that the cloud platform agency service provided with cloud platform access point conversates is long-range meeting
Words connection;
The session connection type that the cloud platform agency service provided with the local gateway of any type conversates is this
Ground session connection.
Further, detection module, specifically for obtaining all session connection types that can be conversated with terminal;
The session attribute to conversate with current cloud platform agency service is extracted, current sessions connection type is obtained;
According to default session connection type priority grade, judge that current sessions connection type is in all session connection types
It is no optimal;
Connection expense and/or stability when the session connection type priority grade is according to session is default.
Further, described device further include:
Bottom communication mode obtains module, connects for obtaining the bottom communication to conversate with current cloud platform agency service
Connect mode;
When bottom communication connection type changes, detection trigger module starts to detect.
The present invention also provides a kind of terminal, the terminal carries out network company using the device of network connection of the present invention
It connects.
The present invention has the beneficial effect that: the present invention passes through cloud platform agency service corresponding with optimal session connection type
Session is established, cloud platform is accessed by the optimal corresponding cloud platform agency service of session connection type, it can be with effective solution
After underlying services switch, when in upper layer communication frame in face of reaching same service there are many connection type simultaneously, on
Layer communications framework cannot be switched to the session connection problem with more excellent connective stability and safety by established session.
Detailed description of the invention
Fig. 1 is a kind of flow chart of the method for network connection in the embodiment of the present invention;
Fig. 2 is the specific switching flow figure that medium-long range session connection of the embodiment of the present invention is switched to local session connection;
Fig. 3 is the specific switching stream that local WIFI session connection is switched to local bluetooth session connection in the embodiment of the present invention
Cheng Tu;
Fig. 4 is a kind of structural schematic diagram of the device of network connection in the embodiment of the present invention.
Specific embodiment
In order to solve the problems, such as that prior art network connective stability is low, the present invention provides a kind of sides of network connection
Method, device and terminal, below in conjunction with attached drawing and embodiment, the present invention will be described in further detail.It should be appreciated that herein
Described specific embodiment is only used to explain the present invention, does not limit the present invention.
Embodiment one
As shown in Figure 1, the embodiment of the present invention provides a kind of method of network connection, comprising:
S101, terminal extract the session attribute to conversate with current cloud platform agency service, obtain current sessions connection
Type.
Wherein, cloud platform agency service is agent application, for providing agency's effect, accesses cloud platform;Cloud platform
For providing the service of resourceoriented;Current cloud platform agency service expression is providing agency's effect, to access cloud platform
Agency service.
Inside of the house, point-to-point communication frame as stated in the background art is used between terminal and local gateway;Therefore,
Local gateway terminaloriented can provide cloud platform agency service, allow flat using the terminal access cloud of point-to-point communication frame
Platform;That is the cloud platform agency service run on local gateway receives the communication data of terminal, and face is converted on gateway
To the data of resource, cloud platform IN is sent to by gateway MN.Local gateway type includes local WIFI gateway and local bluetooth net
Close etc..
In addition, cloud platform is also connected with cloud platform access point.Also cloud platform agency service is run on cloud platform access point, it can
It is interpreted as the gateway outside home network with fixing address, the method for remotely accessing cloud platform IN is provided for household equipment.Eventually
In family's network-external, the client run thereon can remotely connect the agency service of cloud platform access point, establish session at end.
This step in specific implementation, introduces one kind " session connection type " attribute in the attribute of session to identify upper layer
Session connection type when terminal and cloud platform agency service conversate in communications framework.Such as:
connectionType remote 0;
connectionType local 1;
Remote session is connected as remote type, indicates that the cloud platform agency service provided with cloud platform access point is understood
Words;Local session is connected as local type, indicates to carry out with the cloud platform agency service that the local gateway of any type provides
Session.Terminal extracts the session attribute to conversate with current cloud platform agency service, and current sessions connection type can be obtained.
S102, the current sessions connection type that detection conversates with current cloud platform agency service is in the net being presently in
It is whether optimal in network.
This step in specific implementation, obtains all session connection types that can be conversated with terminal;
According to default session connection type priority grade, judge that current sessions connection type is in all session connection types
It is no optimal;That is in the network being presently in, the session connection type of highest priority is in all session connection types
In be optimal.Connection expense and/or stability when wherein session connection type priority grade can be according to session is default.Such as
When including that local session connection is connected with remote session in the network being presently in, meeting is set according to connection expense and stability
Connection priority is talked about, then local session is connected as high priority;Remote session is connected as low priority.For another example it is being presently in
When including the connection of different types of local session in network environment, session connection priority is set according to stability, then it is local
WIFI session connection is high priority;Local bluetooth session connection is low priority.For another example in the network environment being presently in
When including the connection of multiple same type of local sessions, session connection priority is set according to stability, that is to say, that according to
The signal strength that local gateway radiates in same kind sets session connection priority, and signal strength is by force high priority.
S103, when current sessions connection type is not optimal, cloud platform generation corresponding with optimal session connection type
Session is established in reason service, accesses cloud platform by the optimal corresponding cloud platform agency service of session connection type.
Specifically, when the bottom communication connection type to conversate with current cloud platform agency service changes,
Session in upper layer communication frame still conversates with current cloud platform agency service, according to the detection in S102, if
The session connection type to conversate in upper layer communication frame with current cloud platform agency service is low priority, excellent with highest
The corresponding cloud platform agency service of the session connection type of first grade establishes session.
For example, the workflow of above-mentioned network connection is specifically such as Fig. 2 when the terminal of user outside family by being moved in family
It is shown, comprising:
Step 1, terminal remote connects cloud platform access point, establishes the cloud platform agency service provided with cloud platform access point
Session;
Step 2, it is remote according to session connection type, is judged as that remote session connects;
Step 3, terminal enters home network, is switched to family WiFi by 3G/4G, session data is saturating through local WiFi gateway
Pass to cloud platform, there is no switching, what terminal was connected by gateway is still that cloud platform connects for the cloud platform agency service of connection
The cloud platform agency service that access point provides;
Step 4, terminal discovery bottom communication connection type variation, detection can access all cloud platforms agency of cloud platform
Service, obtains all session connection types that can conversate with all cloud platform agency services, i.e., remote session connection and
Local session connection;
Step 5, since the priority of local session connection is higher than the priority of remote session connection, so with optimal meeting
The corresponding cloud platform agency service of words connection type establishes session, that is to say, that acts on behalf of with the cloud platform that local WIFI gateway provides
Session is established in service, and the cloud platform agency service program response terminal run on local WiFi gateway provides local cloud agency clothes
Business;
Step 6, terminal finds local cloud agency service;
Step 7, terminal disconnects the remote session with cloud platform;
Step 8, cloud platform access point detects that terminal connection disconnects, and notifies cloud platform IN;
Step 9, terminal and the cloud platform agency service of local WiFi gateway establish session, access cloud platform by agency;
Step 10, gateway obtains endpoint to register information, is converted into oneM2M resource;
Step 11, terminal resource is registered to MN by gateway A llJoyn service.
For another example, when having local bluetooth gateway and local WiFi gateway in family, terminal can be local blue by bluetooth connection
The cloud platform agency service that tooth gateway provides, the cloud platform agency service through local bluetooth gateway access cloud platform.Terminal may be used also
With the cloud platform agency service provided by local WiFi connection local WiFi gateway, the cloud platform agency through local WiFi gateway
Service access cloud platform.
When beginning, terminal (such as mobile phone) can access local bluetooth by bluetooth except local WiFi gateway range
Gateway.Terminal and the cloud platform of local bluetooth gateway agency establish session, access cloud platform." session company is introduced in session attribute
Connect type " attribute.Herein, session connection type is local bluetooth session connection.
After the terminal is moved in WiFi network, finds the local WiFi session connection service of high priority, will cut
The cloud platform agency service of connection local WiFi gateway is changed to, detailed process is as shown in Figure 3.
Step 1, terminal connects local bluetooth gateway, establishes the meeting of the cloud platform agency service provided with local bluetooth gateway
Words;
Step 2, it is local bluetooth session connection according to session connection type, is judged as bluetooth connection;
Step 3, after terminal is moved in WiFi network, bottom communication being established with local WiFi gateway and is connect, bottom is logical
Letter connection type changes, and acquisition cloud platform informs all cloud platform agency services supported and can be with all cloud platform generations
Whole session connection types (including local bluetooth session connection, local WiFi session connection) that reason service conversates;
Step 4, according to pre-set priority, judgement has the cloud platform agency service of more preferably local WiFi gateway, finds this
The cloud platform agency service of ground WiFi gateway;
Step 5, the cloud platform agency service program response terminal run on local WiFi gateway, it is flat to provide local WiFi cloud
Platform agency service;
Step 6, the cloud platform agency service of terminal discovery local WiFi;
Step 7, terminal disconnects the cloud platform agency service session with local bluetooth gateway;
Step 8, the local bluetooth gateway cloud platform agent advertisement cloud platform equipment has been left;
Step 9, terminal and local WiFi gateway cloud platform agency service establish session, access cloud platform by agency;
Step 10, local WiFi gateway cloud platform agent advertisement cloud platform terminal access.
Session connection is established using service discovery mechanisms due to existing, when the bottom communication connection type of session changes
When, the cloud platform agency service connected in upper layer network frame will not switch, such as when terminal outside family by being moved in family,
For another example when terminal is moved to WiFi network by blueteeth network, gateway plays the role of transparent transmission at this time, and the cloud platform of connection acts on behalf of clothes
There is no switching, the stability of session connection at this time and safety are low for business, and the embodiment of the present invention with optimal session by connecting
It connects the corresponding cloud platform agency service of type and establishes session, pass through the optimal corresponding cloud platform agency service of session connection type
Cloud platform is accessed, can be faced in upper layer communication frame with effective solution while there are many connection types to reach same service
When, after underlying services switch, upper layer communication frame cannot be switched to by established session has more excellent stable connection
The session connection problem of property and safety.
Embodiment two
Embodiment two is the corresponding device of embodiment one, as shown in figure 4, the embodiment of the present invention provides a kind of network connection
Device, comprising:
Detection module 41 is being worked as detecting the current sessions connection type to conversate with current cloud platform agency service
It is whether optimal in preceding locating network, and link block is sent to for will test result;
Link block 42, it is not optimal that the testing result for sending in detection module 41, which is current sessions connection type,
When, cloud platform agency service corresponding with optimal session connection type establishes session, passes through optimal session connection type pair
The cloud platform agency service access cloud platform answered.
Wherein, session connection type includes that remote session connection is connected with local session;It is provided with cloud platform access point
The session connection type that cloud platform agency service conversates is remote session connection;It is provided with the local gateway of any type
The session connection type that conversates of cloud platform agency service be local session connection.
Wherein, detection module 41, specifically for obtaining all session connection types that can be conversated with terminal;
The session attribute to conversate with current cloud platform agency service is extracted, current sessions connection type is obtained;
According to default session connection type priority grade, judge that current sessions connection type is in all session connection types
It is no optimal;
Connection expense and/or stability when the session connection type priority grade is according to session is default.
Bottom communication mode obtains module 43, for obtaining the bottom communication to conversate with current cloud platform agency service
Connection type;When bottom communication connection type changes, detection trigger module starts to detect.
The specific implementation of the device of this law embodiment method referring to described in embodiment one, the device tool of the embodiment of the present invention
There is stable and secure attachment.
Embodiment three
The embodiment of the present invention provides a kind of terminal, which carries out net using the device of network connection described in embodiment two
Network connection, the terminal can be mobile phone, plate, wearable device, camera and other intelligent electronic devices etc..
It should be noted that by this present embodiment comprising all the elements of embodiment one and two, so the present embodiment institute
Stating terminal also has technical effect described in embodiment one and two, and specific therefore not to repeat here.
Although for illustrative purposes, the preferred embodiment of the present invention has been disclosed, those skilled in the art will recognize
It is various improve, increase and replace be also it is possible, therefore, the scope of the present invention should be not limited to the above embodiments.