Summary of the invention
The technical problem to be solved in the present invention is to provide method, device and the terminal that a kind of network connects, in order to solve the low problem of prior art network connective stability.
For solving the problems of the technologies described above, on the one hand, the invention provides a kind of method that network connects, comprising:
Detect the current sessions connection type conversated with the service of current cloud platform agent whether optimum in current residing network;
When current sessions connection type is not optimum, session is set up in the cloud platform agent service corresponding with the session connection type of optimum, by the cloud platform agent service access cloud platform that the session connection type of optimum is corresponding.
Further, described session connection type comprise remote session connect be connected with local session;
Wherein, the session connection type that the cloud platform agent service provided with cloud platform access point conversates is that remote session is connected;
The session connection type that the cloud platform agent service provided with the local gateway of any one type conversates is that local session is connected.
Further, detect the current sessions connection type conversated with the service of current cloud platform agent whether optimum in residing network, specifically comprise:
All session connection types that acquisition can conversate with terminal;
Extract the session attribute conversated with the service of current cloud platform agent, obtain current sessions connection type;
According to default session connection type priority level, judge whether current sessions connection type is optimum in all session connection types.
Further, described session connection type priority level is preset according to connection expense during session and/or stability.
Further, described method also comprises:
Obtain the bottom communication connected mode conversated with the service of current cloud platform agent;
When bottom communication connected mode changes, start to detect the current sessions connection type conversated with the service of current cloud platform agent whether optimum in current residing network.
On the other hand, the device that the present invention also provides a kind of network to connect, comprising:
Detection module, whether optimum in current residing network for detecting the current sessions connection type conversated with the service of current cloud platform agent, and for testing result is sent to link block;
Link block, testing result for sending at detection module is current sessions connection type when not being optimum, session is set up in the cloud platform agent service corresponding with the session connection type of optimum, by the cloud platform agent service access cloud platform that the session connection type of optimum is corresponding.
Further, described session connection type comprise remote session connect be connected with local session;
Wherein, the session connection type that the cloud platform agent service provided with cloud platform access point conversates is that remote session is connected;
The session connection type that the cloud platform agent service provided with the local gateway of any one type conversates is that local session is connected.
Further, detection module, specifically for obtaining all session connection types that can conversate with terminal;
Extract the session attribute conversated with the service of current cloud platform agent, obtain current sessions connection type;
According to default session connection type priority level, judge whether current sessions connection type is optimum in all session connection types;
Described session connection type priority level is preset according to connection expense during session and/or stability.
Further, described device also comprises:
Bottom communication mode acquisition module, for obtaining the bottom communication connected mode conversated with the service of current cloud platform agent;
When bottom communication connected mode changes, detection trigger module starts to detect.
The present invention also provides a kind of terminal, and the device that described terminal adopts network of the present invention to connect carries out network connection.
Beneficial effect of the present invention is as follows: the present invention sets up session by the cloud platform agent service corresponding with the session connection type of optimum, by the cloud platform agent service access cloud platform that the session connection type of optimum is corresponding, can effectively solve after underlying services switches, time in upper layer communication framework in the face of having multiple connected mode to arrive same service simultaneously, upper layer communication framework can not be switched to the session connection problem with more excellent connective stability and fail safe by the session of having set up.
Embodiment
In order to solve the low problem of prior art network connective stability, the invention provides method, device and terminal that a kind of network connects, below in conjunction with accompanying drawing and embodiment, the present invention being further elaborated.Should be appreciated that specific embodiment described herein only in order to explain the present invention, do not limit the present invention.
Embodiment one
As shown in Figure 1, a kind of method that the embodiment of the present invention provides network to connect, comprising:
S101, terminal extracts the session attribute conversated with the service of current cloud platform agent, obtains current sessions connection type.
Wherein, the service of cloud platform agent is agent application, for providing agency to act on, and access cloud platform; Cloud platform is for providing the service of resourceoriented; Current cloud platform agent service represents is providing agency to act on, thus the agency service of access cloud platform.
Portion within the family, adopts point-to-point communication framework as stated in the Background Art between terminal and local gateway; Therefore, local gateway terminaloriented can provide cloud platform agent to serve, and allows the terminal access cloud platform adopting point-to-point communication framework; The communication data of the cloud platform agent service reception terminal that is local gateway run, gateway is converted to the data of resourceoriented, sends to cloud platform IN by gateway MN.Local gateway type comprises local WIFI gateway and local bluetooth gateway etc.
In addition, cloud platform is also connected to cloud platform access point.Cloud platform access point also runs the service of cloud platform agent, can be regarded as the gateway outside home network with fixed address, for household equipment provides the method for long-range access cloud platform IN.Terminal is when family's network-external, and the client that it runs can the agency service of long-range connection cloud platform access point, sets up session.
This step, when specific implementation, introduces session connection type when a kind of " session connection type " attribute identifies that in upper layer communication framework, terminal and the service of cloud platform agent conversate in the attribute of session.Such as:
connectionType remote 0;
connectionType local 1;
Remote session connects for remote type, represents that the cloud platform agent service provided with cloud platform access point conversates; Local session connects for local type, represents that the cloud platform agent service provided with the local gateway of any one type conversates.Terminal extracts the session attribute conversated with the service of current cloud platform agent, can obtain current sessions connection type.
S102, detects the current sessions connection type conversated with the service of current cloud platform agent whether optimum in current residing network.
This step, when specific implementation, obtains all session connection types that can conversate with terminal;
According to default session connection type priority level, judge whether current sessions connection type is optimum in all session connection types; That is, in current residing network, the session connection type that priority is the highest is optimum in all session connection types.Wherein session connection type priority level can be preset according to connection expense during session and/or stability.Such as current residing network comprise local session connect is connected with remote session time, set session connection priority according to connection expense and stability, then local session connection is high priority; Remote session connects for low priority.And for example when current residing network environment comprises dissimilar local session connection, set session connection priority according to stability, then local WIFI session connection is high priority; Local bluetooth session connection is low priority.For another example when the local session that current residing network environment comprises multiple same kind connects, session connection priority is set according to stability, that is according to the signal strength signal intensity setting session connection priority of local gateway radiation in same kind, what signal strength signal intensity was strong is high priority.
S103, when current sessions connection type is not optimum, session is set up in the cloud platform agent service corresponding with the session connection type of optimum, by the cloud platform agent service access cloud platform that the session connection type of optimum is corresponding.
Specifically, when the bottom communication connected mode conversated with the service of current cloud platform agent changes, its session in upper layer communication framework still conversates with the service of current cloud platform agent, according to the detection in S102, if the session connection type conversated with the service of current cloud platform agent in upper layer communication framework is low priority, session is set up in the cloud platform agent service corresponding with the session connection type of limit priority.
Such as, when the terminal of user is by moving in family outside family, the workflow that above-mentioned network connects is concrete as shown in Figure 2, comprising:
Step 1, terminal remote connects cloud platform access point, the session that the cloud platform agent that setting up provides with cloud platform access point is served;
Step 2 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, and session data is transparent to cloud platform through local WiFi gateway, the cloud platform agent service connected does not switch, and what terminal was connected by gateway remains the cloud platform agent service that cloud platform access point provides;
Step 4, the change of terminal discovery bottom communication connected mode, detect all cloud platform agent services that can access cloud platform, obtain all session connection types that can conversate with the service of all cloud platform agent, namely remote session connection is connected with local session;
Step 5, due to the priority that the priority of local session connection connects higher than remote session, so session is set up in the cloud platform agent service corresponding with the session connection type of optimum, that is session is set up in the cloud platform agent service provided with local WIFI gateway, the cloud platform agent service routine response terminal that local WiFi gateway runs, provides local cloud agency service;
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 connects and disconnects, notice cloud platform IN;
Step 9, session is set up in the cloud platform agent service of terminal and local WiFi gateway, by agency's access cloud platform;
Step 10, gateway obtains endpoint registration information, is converted into oneM2M resource;
Step 11, terminal resource is registered to MN by gateway A llJoyn service.
And for example, when having local bluetooth gateway and local WiFi gateway in family, terminal can connect by bluetooth the cloud platform agent service that local bluetooth gateway provides, through the cloud platform agent service access cloud platform of local bluetooth gateway.Terminal can also connect by local WiFi the cloud platform agent service that local WiFi gateway provides, through the cloud platform agent service access cloud platform of local WiFi gateway.
During beginning, terminal (as mobile phone) outside local WiFi gateway scope, but accesses local bluetooth gateway by bluetooth.The cloud platform agent of terminal and local bluetooth gateway sets up session, access cloud platform." session connection type " attribute is introduced in session attribute.Herein, session connection type is local bluetooth session connection.
After in this fast mobile terminal to WiFi network, find the local WiFi session connection service of high priority, just can be switched to the cloud platform agent service connecting local WiFi gateway, idiographic flow as shown in Figure 3.
Step 1, terminal connects local bluetooth gateway, the session that the cloud platform agent that setting up provides with local bluetooth gateway is served;
Step 2 is local bluetooth session connection according to session connection type, is judged as that bluetooth connects;
Step 3, after in fast mobile terminal to WiFi network, set up bottom communication with local WiFi gateway to be connected, bottom communication connected mode changes, and obtains all cloud platform agent services that support informed by cloud platform and whole session connection types (comprising local bluetooth session connection, local WiFi session connection) that can conversate with the service of all cloud platform agent;
Step 4, according to pre-set priority, judges have the cloud platform agent of more excellent local WiFi gateway to serve, and finds the cloud platform agent service of local WiFi gateway;
Step 5, the cloud platform agent service routine response terminal that local WiFi gateway runs, provides local WiFi cloud platform agent to serve;
Step 6, terminal finds the cloud platform agent service of local WiFi;
Step 7, terminal disconnects the cloud platform agent service conversation with local bluetooth gateway;
Step 8, this equipment of local bluetooth gateway cloud platform agent notice cloud platform leaves;
Step 9, session is set up in terminal and the service of local WiFi gateway cloud platform agent, by agency's access cloud platform;
Step 10, the access of local WiFi gateway cloud platform agent notice cloud platform terminal.
Because existing employing service discovery mechanisms sets up session connection, when the bottom communication connected mode change of session, the cloud platform agent service connected in upper layer network framework can not switch, such as when terminal is by moving in family outside family, and for example when terminal moves to WiFi network by blueteeth network, now gateway plays the effect of transparent transmission, the cloud platform agent service connected does not switch, stability and the fail safe of now session connection are low, the embodiment of the present invention sets up session by the cloud platform agent service corresponding with the session connection type of optimum, by the cloud platform agent service access cloud platform that the session connection type of optimum is corresponding, when having multiple connected mode to arrive same service faced by can effectively solving in upper layer communication framework simultaneously, after underlying services switches, upper layer communication framework can not be switched to the session connection problem with more excellent connective stability and fail safe by the session of having set up.
Embodiment two
Embodiment two is the device of embodiment one correspondence, and as shown in Figure 4, the device that the embodiment of the present invention provides a kind of network to connect, comprising:
Detection module 41, whether optimum in current residing network for detecting the current sessions connection type conversated with the service of current cloud platform agent, and for testing result is sent to link block;
Link block 42, testing result for sending at detection module 41 is current sessions connection type when not being optimum, session is set up in the cloud platform agent service corresponding with the session connection type of optimum, by the cloud platform agent service access cloud platform that the session connection type of optimum is corresponding.
Wherein, session connection type comprises remote session connection and is connected with local session; The session connection type that the cloud platform agent service provided with cloud platform access point conversates is that remote session is connected; The session connection type that the cloud platform agent service provided with the local gateway of any one type conversates is that local session is connected.
Wherein, detection module 41, specifically for obtaining all session connection types that can conversate with terminal;
Extract the session attribute conversated with the service of current cloud platform agent, obtain current sessions connection type;
According to default session connection type priority level, judge whether current sessions connection type is optimum in all session connection types;
Described session connection type priority level is preset according to connection expense during session and/or stability.
Bottom communication mode acquisition module 43, for obtaining the bottom communication connected mode conversated with the service of current cloud platform agent; When bottom communication connected mode changes, detection trigger module starts to detect.
The specific implementation of the device of this law embodiment is with reference to the method described in embodiment one, and the device of the embodiment of the present invention has connectivity that is stable and safety.
Embodiment three
The embodiment of the present invention provides a kind of terminal, and the device that this terminal adopts the network described in embodiment two to connect carries out network connection, and this terminal can be mobile phone, flat board, wearable device, camera and other intelligent electronic devices etc.
It should be noted that, owing to comprising all the elements of embodiment one and two in the present embodiment, so terminal described in the present embodiment also has the technique effect described in embodiment one and two, specifically therefore not to repeat here.
Although be example object, disclose the preferred embodiments of the present invention, it is also possible for those skilled in the art will recognize various improvement, increase and replacement, and therefore, scope of the present invention should be not limited to above-described embodiment.