CN113746934B - Service connection method and electronic equipment - Google Patents

Service connection method and electronic equipment Download PDF

Info

Publication number
CN113746934B
CN113746934B CN202111076617.8A CN202111076617A CN113746934B CN 113746934 B CN113746934 B CN 113746934B CN 202111076617 A CN202111076617 A CN 202111076617A CN 113746934 B CN113746934 B CN 113746934B
Authority
CN
China
Prior art keywords
target service
connection
heartbeat
equipment
identifier
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
CN202111076617.8A
Other languages
Chinese (zh)
Other versions
CN113746934A (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.)
Pi Technology Changzhou Co ltd
Original Assignee
Pi Technology Changzhou 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 Pi Technology Changzhou Co ltd filed Critical Pi Technology Changzhou Co ltd
Priority to CN202111076617.8A priority Critical patent/CN113746934B/en
Publication of CN113746934A publication Critical patent/CN113746934A/en
Application granted granted Critical
Publication of CN113746934B publication Critical patent/CN113746934B/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
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/14Session management
    • H04L67/141Setup of application sessions
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L43/00Arrangements for monitoring or testing data switching networks
    • H04L43/10Active monitoring, e.g. heartbeat, ping or trace-route
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/14Session management
    • H04L67/143Termination or inactivation of sessions, e.g. event-controlled end of session
    • H04L67/145Termination or inactivation of sessions, e.g. event-controlled end of session avoiding end of session, e.g. keep-alive, heartbeats, resumption message or wake-up for inactive or interrupted session

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Health & Medical Sciences (AREA)
  • Cardiology (AREA)
  • General Health & Medical Sciences (AREA)
  • Mobile Radio Communication Systems (AREA)

Abstract

The embodiment of the invention discloses a service connection method and electronic equipment, which are used for quickly recovering a service connection state. In the service connection method of the embodiment of the invention, the first device and the second device establish heartbeat connection. When the first device acquires the target service information sent by the second device, the heartbeat response acquired by the first device comprises the target service identifier. The first device performs a target operation using the target service information. When the first equipment and the second equipment are disconnected with each other, the first equipment and the second equipment reestablish the heartbeat connection so that the second equipment sends a heartbeat response comprising the target service identifier to the first equipment. When the first device detects that the heartbeat response comprises the target service identifier, the first device applies the target service information acquired from the second device to re-execute the target operation. After the first device and the second device are restored to be connected, the state of service connection can be quickly restored.

Description

Service connection method and electronic equipment
Technical Field
The present invention relates to the field of communications, and in particular, to a service connection method and an electronic device.
Background
Currently, users often use multiple terminals to perform operations on a service, for example, one device obtains service information and sends the service information to another device for the other device to operate the service information.
Because of unstable network or equipment problem, communication between two devices executing service together is interrupted, if two devices resume communication, the originally executed service is stopped and the original service cannot be executed continuously, which brings inconvenience to users and is unfavorable for smooth execution of service.
Disclosure of Invention
The embodiment of the invention provides a service connection method and electronic equipment, which are used for quickly recovering a service connection state.
To achieve the purpose, the embodiment of the invention adopts the following technical scheme:
a service connection method, comprising:
the method comprises the steps that a first device and a second device establish heartbeat connection, wherein the heartbeat connection is that a heartbeat instruction is sent to the second device by the first device every preset time, so that a heartbeat response is sent to the first device by the second device, and the heartbeat response does not comprise a target service identifier;
when the first device acquires target service information sent by the second device, the heartbeat response acquired by the first device includes the target service identifier, where the target service identifier is used to indicate a state that the second device executes a target service to obtain the target service information;
The first equipment applies the target service information to execute target operation;
when the first device and the second device disconnect the heartbeat connection, the first device and the second device reestablish the heartbeat connection so that the second device sends the heartbeat response comprising the target service identifier to the first device, wherein the second device keeps executing the target service during the period that the first device and the second device disconnect the heartbeat connection so as to obtain the target service information;
and when the first equipment detects that the heartbeat response comprises the target service identifier, the first equipment applies the target service information acquired from the second equipment to re-execute the target operation.
Optionally, before the first device and the second device establish the heartbeat connection, the method further includes:
the first equipment and the second equipment establish communication connection;
after the first device and the second device disconnect the heartbeat connection and before the first device and the second device reestablish the heartbeat connection, the method further includes:
the first device and the second device reestablish a communication connection.
Optionally, when the first device acquires the target service information sent by the second device, the heartbeat response acquired by the first device includes the target service identifier, including:
the first device sends a target service triggering instruction to the second device so that the second device executes the target service to obtain the target service information, and generates the heartbeat response comprising the target service identifier;
the first device obtains the target service information sent by the second device and the heartbeat response including the target service identifier.
Optionally, the first device and the second device establish a communication connection, including:
the method comprises the steps that a first device sends a first connection request to a second device, so that the second device generates a connection response comprising a connection identifier and stores the connection identifier, wherein the first connection request does not comprise the connection identifier;
the first equipment acquires the connection response sent by the second equipment so as to establish communication connection between the first equipment and the second equipment;
the first equipment records the connection identifier;
the first device and the second device reestablish communication connection, including:
The first device sends a second connection request comprising the connection identifier to the second device, so that the second device generates the connection response when detecting that the connection identifier stored locally is the same as the connection identifier on the second connection request;
and the first equipment acquires the connection response sent by the second equipment so as to realize the reestablishment of communication connection between the first equipment and the second equipment.
Optionally, the disconnecting the heartbeat connection by the first device and the second device includes:
if the first device does not acquire the heartbeat response from the second device within the target disconnection time, the first device determines to disconnect the heartbeat connection with the second device;
the first device is a playing device;
the second device is an image pickup device;
the target service information is video information;
the target service is to collect the video information;
the target operates to play the video information.
To achieve the purpose, the embodiment of the invention also adopts the following technical scheme:
a service connection method, comprising:
the method comprises the steps that a heartbeat connection is established between second equipment and first equipment, wherein the heartbeat connection is that a heartbeat instruction is sent to the second equipment by the first equipment every preset time, so that a heartbeat response is sent to the first equipment by the second equipment, and the heartbeat response does not comprise a target service identifier;
The second device executes a target service to obtain target service information, and generates the heartbeat response including the target service identifier, wherein the target service identifier is used for indicating a state that the second device executes the target service to obtain the target service information;
the second device sends the target service information to the first device, and the heartbeat response including the target service identifier, so that the first device executes target operation by applying the target service information;
after the first device and the second device disconnect the heartbeat connection, the second device maintains to execute the target service so as to obtain the target service information;
the second device and the first device reestablish the heartbeat connection;
the second device sends the target service information to the first device, and the heartbeat response including the target service identifier, so that when the first device detects that the heartbeat response includes the target service identifier, the first device uses the target service information to re-execute the target operation.
Optionally, before the second device and the first device establish the heartbeat connection, the method further includes:
The second equipment and the first equipment establish communication connection;
after the first device and the second device disconnect the heartbeat connection and before the second device and the first device reestablish the heartbeat connection, the method further includes:
the second device reestablishes communication connection with the first device.
Optionally, the second device executes a target service to obtain target service information, and generates the heartbeat response including the target service identifier, including:
when the second device acquires a target service triggering instruction sent by the first device, the second device executes target service to obtain target service information, and generates the heartbeat response comprising the target service identifier;
wherein the first device is a playing device;
the second device is an image pickup device;
the target service information is video information;
the target service is to collect the video information;
the target operates to play the video information.
Optionally, the second device establishes a communication connection with the first device, including:
when a second device obtains a first connection request which is sent by a first device and does not comprise a connection identifier, the second device generates a connection response comprising the connection identifier and stores the connection identifier;
The second device sends the connection response to the first device so as to enable the second device to establish communication connection with the first device, and enable the first device to record the connection identification;
the second device reestablishing a communication connection with the first device, comprising:
the second device obtains a second connection request which is sent by the first device and comprises the connection identifier;
generating the connection response when the second device detects that the locally stored connection identifier is the same as the connection identifier on the second connection request;
and the second equipment sends the connection response to the first equipment so as to realize the reestablishment of communication connection between the second equipment and the first equipment.
Optionally, after the first device and the second device disconnect the heartbeat connection, the method further includes:
when the disconnection timeout time is not exceeded and the second device acquires a third connection request sent by a third device, the second device refuses to connect the third device, wherein the disconnection timeout time is a preset duration from each time when the heartbeat instruction is acquired;
And when the second device and the first device do not reestablish the heartbeat connection within the disconnection timeout time, and the second device acquires the third connection request sent by the third device after the disconnection timeout time, the second device and the third device establish communication connection.
To achieve the purpose, the embodiment of the invention also adopts the following technical scheme:
an electronic device, comprising:
the device comprises an establishing unit, a first device and a second device, wherein the establishing unit is used for establishing heartbeat connection with the second device, the heartbeat connection is that the first device sends a heartbeat instruction to the second device every preset time so that the second device sends a heartbeat response to the first device, and the heartbeat response does not comprise a target service identifier;
the acquisition unit is used for acquiring the heartbeat response comprising the target service identifier when the first device acquires the target service information sent by the second device, wherein the target service identifier is used for indicating the state that the second device executes the target service to acquire the target service information;
the application unit is used for applying the target service information to execute target operation;
the establishing unit is further configured to reestablish a heartbeat connection with the second device after the first device and the second device disconnect the heartbeat connection, so that the second device sends the heartbeat response including the target service identifier to the first device, where the second device maintains to execute the target service during the period when the first device and the second device disconnect the heartbeat connection, so as to obtain the target service information;
A service application unit, configured to, when the first device detects that the heartbeat response includes the target service identifier, re-execute the target operation by applying the target service information acquired from the second device;
the first device is the electronic device.
Optionally, the electronic device further includes a communication connection unit;
the communication connection unit is used for establishing communication connection with the second equipment before the first equipment and the second equipment establish heartbeat connection;
the communication connection unit is further configured to reestablish a communication connection with the second device after the first device and the second device disconnect the heartbeat connection and before the first device and the second device reestablish the heartbeat connection.
Optionally, the electronic device further comprises a transmitting unit;
the sending unit is configured to send a target service triggering instruction to the second device, so that the second device executes the target service to obtain the target service information, and generate the heartbeat response including the target service identifier;
the acquiring unit is further configured to acquire the target service information sent by the second device and the heartbeat response including the target service identifier.
Optionally, the communication connection unit comprises a sending module, an obtaining module and a recording module;
the sending module is used for sending a first connection request to second equipment so that the second equipment generates a connection response comprising a connection identifier and stores the connection identifier, wherein the first connection request does not comprise the connection identifier;
the acquisition module is used for acquiring the connection response sent by the second equipment so as to realize that the first equipment and the second equipment establish communication connection;
the recording module is used for recording the connection identifier;
the sending module is further configured to send a second connection request including the connection identifier to the second device, so that the second device generates the connection response when detecting that the locally stored connection identifier is the same as the connection identifier on the second connection request;
the acquisition module is further configured to acquire the connection response sent by the second device, so as to achieve the purpose that the first device and the second device reestablish communication connection.
Optionally, the electronic device further comprises a disconnection determining unit;
the disconnection determining unit is used for determining to disconnect the heartbeat connection with the second device if the first device does not acquire the heartbeat response from the second device within the target disconnection time;
The first device is a playing device;
the second device is an image pickup device;
the target service information is video information;
the target service is to collect the video information;
the target operates to play the video information.
To achieve the purpose, the embodiment of the invention also adopts the following technical scheme:
an electronic device, comprising:
the device comprises an establishing unit, a first device and a second device, wherein the establishing unit is used for establishing heartbeat connection with the first device, the heartbeat connection is that the first device sends a heartbeat instruction to the second device every preset time so that the second device sends a heartbeat response to the first device, and the heartbeat response does not comprise a target service identifier;
the execution unit is used for executing a target service to obtain target service information and generating the heartbeat response comprising the target service identifier, wherein the target service identifier is used for indicating the state that the second equipment executes the target service to obtain the target service information;
a sending unit, configured to send the target service information to the first device, and the heartbeat response including the target service identifier, so that the first device performs a target operation by applying the target service information;
The execution unit is further configured to maintain execution of the target service after the first device and the second device disconnect the heartbeat connection, so as to obtain the target service information;
the establishing unit is further configured to reestablish the heartbeat connection with the first device;
the sending unit is further configured to send the target service information to the first device, and the heartbeat response including the target service identifier, so that when the first device detects that the heartbeat response includes the target service identifier, the first device executes the target operation again by applying the target service information;
the second device is the electronic device.
Optionally, the electronic device further includes a communication connection unit;
the communication connection unit is used for establishing communication connection with the first equipment before the second equipment and the first equipment establish heartbeat connection;
the communication connection unit is further configured to reestablish a communication connection with the first device after the first device and the second device disconnect the heartbeat connection and before the second device and the first device reestablish the heartbeat connection.
Optionally, the executing unit is further configured to execute a target service when the second device obtains a target service trigger instruction sent by the first device, so as to obtain target service information, and generate the heartbeat response including the target service identifier;
wherein the first device is a playing device;
the second device is an image pickup device;
the target service information is video information;
the target service is to collect the video information;
the target operates to play the video information.
Optionally, the communication connection unit comprises a generation module, a sending module, an acquisition module and a storage module;
the generating module is used for generating a connection response comprising the connection identifier when the second device acquires a first connection request which is sent by the first device and does not comprise the connection identifier;
the storage module is used for storing the connection identifier;
the sending module is used for sending the connection response to the first equipment so as to realize that the second equipment and the first equipment establish communication connection, and the first equipment records the connection identifier;
the acquisition module is used for acquiring a second connection request which is sent by the first equipment and comprises the connection identifier;
The generating module is further configured to generate the connection response when detecting that the locally stored connection identifier is the same as the connection identifier on the second connection request;
the sending module is further configured to send the connection response to the first device, so that the second device and the first device reestablish communication connection.
Optionally, the communication connection unit is further configured to reject connection to a third device when a disconnection timeout period is not exceeded after the first device and the second device disconnect the heartbeat, and the second device obtains a third connection request sent by the third device, where the disconnection timeout period is a preset duration from when the heartbeat command is obtained each time; and when the second device and the first device do not reestablish the heartbeat connection within the disconnection timeout time, and the second device acquires the third connection request sent by the third device after the disconnection timeout time, establishing communication connection with the third device.
From the above technical solutions, the embodiment of the present invention has the following advantages:
In the service connection method of the embodiment of the invention, the first device and the second device establish heartbeat connection, wherein the heartbeat connection is that the first device sends a heartbeat instruction to the second device every preset time so that the second device sends a heartbeat response to the first device, and the heartbeat response does not comprise the target service identifier. When the first device acquires the target service information sent by the second device, the heartbeat response acquired by the first device includes a target service identifier, where the target service identifier is used to indicate a state that the second device executes the target service to obtain the target service information. The first device performs a target operation using the target service information. When the first equipment and the second equipment are disconnected, the first equipment and the second equipment reestablish the heartbeat connection so that the second equipment sends a heartbeat response comprising the target service identification to the first equipment, wherein the second equipment maintains to execute the target service during the period that the first equipment and the second equipment are disconnected to obtain the target service information. When the first device detects that the heartbeat response comprises the target service identifier, the first device applies the target service information acquired from the second device to re-execute the target operation. Thus, even if the first device and the second device are disconnected, after the first device and the second device are restored to be connected, the first device can re-execute the target operation by using the target service information acquired from the second device, so that the service connection state can be quickly restored.
Drawings
Fig. 1 is a usage scenario diagram of a service connection method according to an embodiment of the present invention;
fig. 2 is a flowchart of a service connection method according to another embodiment of the present invention;
fig. 3 is a flowchart of a service connection method according to another embodiment of the present invention;
fig. 4 is a flowchart of a service connection method according to another embodiment of the present invention;
fig. 5 is a schematic structural diagram of an electronic device according to another embodiment of the present invention;
fig. 6 is a schematic structural diagram of an electronic device according to another embodiment of the present invention.
Detailed Description
The embodiment of the invention provides a service connection method and electronic equipment, which are used for quickly recovering a service connection state.
Fig. 1 is a usage scenario diagram of a service connection method according to an embodiment of the present invention. In the use scene, the first equipment and the second equipment can communicate, and the transmission of the target service information is realized. Such as Wi-Fi connection, or wireless communication such as mobile network communication, or wired connection communication. For example, the first device is a playback device 101, the second device is an image capturing device 102, and the service is a video service. At this time, after the image capturing device collects the video information, the image capturing device sends the video information to the playing device, so that the playing device plays the video information, and thus, the service cooperation between the playing device and the image capturing device can be implemented.
However, because of unstable network or equipment problem, communication between the playing equipment and the image capturing equipment is sometimes interrupted, so that the video service is temporarily interrupted.
It should be understood that the first device is a playing device, the second device is an image capturing device, and the service is a video service, which is only exemplary, and the service connection method in the embodiment of the present invention is not specifically limited.
Fig. 2 is a flowchart of a service connection method according to another embodiment of the present invention. The service connection method of the embodiment shown in fig. 2 may be applied to the usage scenario of the embodiment shown in fig. 1.
Referring to fig. 2, a service connection method according to an embodiment of the present invention includes:
step 201: the first device and the second device establish a heartbeat connection.
The heartbeat connection is that the first equipment sends a heartbeat instruction to the second equipment every preset time, so that the second equipment sends a heartbeat response to the first equipment, and the heartbeat response does not comprise the target service identification. The heartbeat response may carry information, and when the second device does not perform the target service, the heartbeat response does not include the target service identifier.
The first device and the second device are connected through the heartbeat, the connection maintenance can be determined, and if the heartbeat response carries the state information of the second device, the first device can acquire the current state of the second device through the heartbeat response.
Optionally, before the first device and the second device establish the heartbeat connection, the method in the embodiment of the present invention further includes: the first device and the second device establish a communication connection.
The first device and the second device may establish a communication connection prior to cooperatively executing the service. The communication connection means that the first device and the second device allow each other to communicate.
There are various ways of establishing communication connection, for example, finding a communication device through a network protocol, and obtaining an IP address of the other party as an identifier, or establishing a field allowing communication, which is not particularly limited in the embodiment of the present invention.
Step 202: when the first device acquires the target service information sent by the second device, the heartbeat response acquired by the first device comprises the target service identifier.
The target service identifier is used for indicating the state that the second device executes the target service to obtain the target service information. Thus, by reading the target service identification, the first device can determine that the second device is currently in a state of executing the target service.
Step 203: the first device performs a target operation using the target service information.
After the target service information is acquired, the first device applies the target service information to execute the target operation. Thus, the first device and the second device cooperatively execute the service.
Optionally, in some embodiments, step 203 specifically includes: when the first device detects that the heartbeat response comprises the target service identifier, the first device applies the target service information to execute the target operation. In other words, the first device performs the target operation using the target traffic information, requiring triggering of the target traffic identification on the heartbeat response.
Optionally, in some embodiments, step 203 specifically includes: the first device applies the target service information and the target service identifier to execute the target operation. For example, the target operates to simultaneously display target traffic information and target traffic identification.
Step 204: when the first equipment and the second equipment are disconnected with each other, the first equipment and the second equipment reestablish the heartbeat connection so that the second equipment sends a heartbeat response comprising the target service identifier to the first equipment.
Wherein the second device maintains executing the target service during the period when the first device and the second device disconnect the heartbeat, so as to obtain the target service information.
After the first device and the second device disconnect the heartbeat connection, in order to maintain the connection, the first device and the second device reestablish the heartbeat connection, at this time, every preset time, the first device sends a heartbeat instruction to the second device so that the second device sends a heartbeat response to the first device, because the second device still maintains to execute the target service to obtain the target service information, and the target service identifier is used for indicating the state that the second device executes the target service to obtain the target service information. Thus, the heartbeat response includes the target traffic identification.
Optionally, after the first device and the second device disconnect the heartbeat connection and before the first device and the second device reestablish the heartbeat connection, the method of the embodiment of the present invention further includes: the first device and the second device reestablish the communication connection.
After the first device and the second device disconnect the heartbeat, the second device maintains to execute the target service to obtain the target service information.
The first device and the second device are disconnected from the heartbeat connection, and communication between the first device and the second device is often interrupted at the moment, so that transmission of the target service information is also interrupted. However, at this time, the second device still maintains executing the target service to obtain the target service information.
After the first device and the second device disconnect the heartbeat connection and before the first device and the second device reestablish the heartbeat connection, in the network, in order to find the other party, the first device and the second device reestablish the communication connection. The communication connection means that the first device and the second device allow each other to communicate.
Step 205: when the first device detects that the heartbeat response comprises the target service identifier, the first device applies the target service information acquired from the second device to re-execute the target operation.
The first equipment detects that the heartbeat response comprises a target service identifier, and determines that the second equipment is in a state of executing target service to obtain target service information through the target service identifier, and after the first equipment acquires the target service information from the second equipment, the first equipment executes target operation by applying the target service information. Therefore, after the first equipment and the second equipment interrupt communication, the first equipment can quickly resume the execution target operation, and the first equipment and the second equipment can quickly resume the service connection state.
In summary, in the service connection method according to the embodiment of the present invention, the first device and the second device establish a heartbeat connection, where the heartbeat connection is that the first device sends a heartbeat instruction to the second device every preset time, so that the second device sends a heartbeat response to the first device, and the heartbeat response does not include the target service identifier. When the first device acquires the target service information sent by the second device, the heartbeat response acquired by the first device includes a target service identifier, where the target service identifier is used to indicate a state that the second device executes the target service to obtain the target service information. The first device performs a target operation using the target service information. When the first equipment and the second equipment are disconnected, the first equipment and the second equipment reestablish the heartbeat connection so that the second equipment sends a heartbeat response comprising the target service identification to the first equipment, wherein the second equipment maintains to execute the target service during the period that the first equipment and the second equipment are disconnected to obtain the target service information. When the first device detects that the heartbeat response comprises the target service identifier, the first device applies the target service information acquired from the second device to re-execute the target operation. Thus, even if the first device and the second device are disconnected, after the first device and the second device are restored to be connected, the first device can re-execute the target operation by using the target service information acquired from the second device, so that the service connection state can be quickly restored.
Fig. 3 is a flowchart of a service connection method according to another embodiment of the present invention. The service connection method of the embodiment shown in fig. 3 may be applied to the usage scenario of the embodiment shown in fig. 1.
Referring to fig. 3, a service connection method according to an embodiment of the present invention includes:
step 301: the second device establishes a heartbeat connection with the first device.
The heartbeat connection is that the first equipment sends a heartbeat instruction to the second equipment every preset time, so that the second equipment sends a heartbeat response to the first equipment, and the heartbeat response does not comprise the target service identification.
The first device and the second device are connected through the heartbeat, the connection maintenance can be determined, and if the heartbeat response carries the state information of the second device, the first device can acquire the current state of the second device through the heartbeat response.
Optionally, before the second device and the first device establish the heartbeat connection, the method in the embodiment of the present invention further includes: the second device establishes a communication connection with the first device.
The first device and the second device may establish a communication connection prior to cooperatively executing the service. The communication connection means that the first device and the second device allow each other to communicate.
There are various ways of establishing a communication connection, for example, finding a device for communication through a network protocol, and acquiring an internet protocol (Internet Protocol, IP) address of the other party as an identifier, or establishing a field for allowing communication, which is not particularly limited in the embodiment of the present invention.
Step 302: the second device executes the target service to obtain target service information, and generates a heartbeat response including the target service identification.
The target service identifier is used for indicating the state that the second device executes the target service to obtain the target service information.
And the second equipment executes the target service to obtain target service information. The current state of the second device is a state in which the target service is executed to obtain target service information. The second device generates a target service identity to represent the status by the target service identity. The second device generates a heartbeat response including the target traffic identification. In the heartbeat connection, the first device sends a heartbeat instruction to the second device every preset time. After receiving the heartbeat instruction, the second device sends a heartbeat response to the first device, and at this time, the heartbeat response includes the target service identifier.
Step 303: the second device sends the target service information to the first device, and a heartbeat response including the target service identification.
The second device sends the target service information to the first device, and the heartbeat response including the target service identifier, so that the first device can execute the target operation by applying the target service information. In addition, by reading the target service identification, the first device may determine a current state in which the second device performs the target service.
Optionally, the second device sends the target service information to the first device, and the heartbeat response including the target service identifier, and may further cause the first device to apply the target service information to perform the target operation when the first device detects that the heartbeat response includes the target service identifier. Or, the first device is enabled to apply the target service information and the target service identifier to execute the target operation.
Step 304: after the first device and the second device disconnect the heartbeat, the second device maintains to execute the target service to obtain the target service information.
The first device and the second device are disconnected from the heartbeat, so that communication between the first device and the second device is often interrupted, and transmission of target service information is also interrupted. However, at this time, the second device maintains execution of the target service to obtain the target service information, but the target service information is temporarily unable to be transmitted to the first device.
When the first device and the second device disconnect the heartbeat connection, the first device and the second device may reestablish the heartbeat connection.
Step 305: the second device reestablishes the heartbeat connection with the first device.
The second device and the first device reestablish the heartbeat connection, and the connection stability can be maintained.
Optionally, after the first device and the second device disconnect the heartbeat connection and before the second device and the first device reestablish the heartbeat connection, the method of the embodiment of the present invention further includes: the second device reestablishes the communication connection with the first device.
The first device and the second device are disconnected from the heartbeat connection, and at this time, communication between the second device and the first device is often interrupted, and transmission of the target service information is also interrupted. However, at this time, the second device still maintains executing the target service to obtain the target service information.
After the first device and the second device disconnect the heartbeat connection and before the second device and the first device reestablish the heartbeat connection, in the network, in order to find the other party, the first device and the second device reestablish the communication connection. The communication connection means that the first device and the second device allow each other to communicate.
Step 306: the second device sends the target service information to the first device, and a heartbeat response including the target service identification.
The second device and the first device reestablish the heartbeat connection, at this time, every preset time, the first device sends a heartbeat instruction to the second device, so that the second device sends a heartbeat response to the first device, and the second device maintains to execute the target service to obtain the target service information, that is, the state of the second device is the state of executing the target service to obtain the target service information, so that the heartbeat response includes the target service identifier to indicate the state of the second device.
The second device sends the target service information to the first device and a heartbeat response including the target service identification, so that the first device re-performs the target operation by applying the target service information when detecting that the heartbeat response includes the target service identification.
When the first device detects that the heartbeat response comprises the target service identifier, the first device determines that the second device is in a state of executing the target service to obtain target service information by reading the target service identifier, and after the first device acquires the target service information from the second device, the first device executes target operation by applying the target service information. Therefore, after the first equipment and the second equipment interrupt communication, the first equipment can quickly resume the execution target operation, and the first equipment and the second equipment can quickly resume the service connection state.
In summary, in the service connection method according to the embodiment of the present invention, the second device and the first device establish a heartbeat connection, where the heartbeat connection is that the first device sends a heartbeat instruction to the second device every preset time, so that the second device sends a heartbeat response to the first device, and the heartbeat response does not include the target service identifier. The second device executes the target service to obtain target service information, and generates a heartbeat response including a target service identifier, where the target service identifier is used to indicate a state in which the second device executes the target service to obtain the target service information. The second device sends the target service information to the first device, and the heartbeat response including the target service identifier, so that the first device can execute the target operation by applying the target service information. After the first device and the second device disconnect the heartbeat, the second device maintains to execute the target service to obtain the target service information. The second device reestablishes the heartbeat connection with the first device. The second device sends the target service information to the first device and a heartbeat response including the target service identification, so that the first device re-performs the target operation by applying the target service information when detecting that the heartbeat response includes the target service identification. Thus, even if the first device and the second device are disconnected, after the first device and the second device are restored to be connected, the second device sends the target service information to the first device, and the first device re-executes the target operation by applying the target service information, so that the service connection state is quickly restored.
Fig. 4 is a flowchart of a service connection method according to another embodiment of the present invention. The service connection method of the embodiment shown in fig. 4 may be implemented based on the service connection methods of the embodiments shown in fig. 2 and 3, and the service connection method of the embodiment shown in fig. 4 may be applied to the usage scenario of the embodiment shown in fig. 1.
In the embodiment shown in fig. 4, in order to more intuitively understand the scheme, in some examples, the first device is a playing device, the second device is a camera device, the target service information is video information, the target service is to collect video information, and the target operation is to play video information. It should be understood that these examples are illustrative only and are not intended to limit the embodiments of the invention in any way.
Referring to fig. 4, a service connection method according to an embodiment of the present invention includes:
step 401: the first device and the second device establish a communication connection.
The first device and the second device may establish a communication connection prior to cooperatively executing the service. The communication connection means that the first device and the second device allow each other to communicate. There are various ways of establishing communication connection, for example, finding a communication device through a network protocol, and obtaining an IP address of the other party as an identifier, or establishing a field allowing communication, which is not particularly limited in the embodiment of the present invention.
In a specific example, step 401 includes: the first device sends a first connection request to the second device to cause the second device to generate a connection response including the connection identification and store the connection identification, wherein the first connection request does not include the connection identification. At this time, at the second device side, when the second device obtains the first connection request which is sent by the first device and does not include the connection identifier, the second device generates a connection response including the connection identifier, and the second device stores the connection identifier. The second equipment sends a connection response to the first equipment, and the first equipment acquires the connection response sent by the second equipment so as to realize that the first equipment and the second equipment establish communication connection. The first device may record the connection identity. In this way, the first device and the second device are both connected by establishing the communication connection, and the connection identifier is used for identifying and recording the communication connection, so that the first device and the second device mutually allow the other device to communicate.
The first device and the second device mutually send information, which can be achieved by using an IP address and a port number, the first device sends information to the second device by using the IP address and the port number of the second device, and the second device sends information to the second device by using the IP address and the port number of the first device. If the first device and the second device have no opposite information at the beginning, the first device can find the second device in the network through broadcasting and inform the second device of the IP address and the port number of the first device, and the second device also feeds back the IP address and the port number of the second device to the first device.
For example, the playback apparatus transmits a connection probe request to the image capturing apparatus by user datagram protocol (User Datagram Protocol, UDP) broadcast in the local area network, and after the image capturing apparatus acquires the connection probe request, transmits a connection probe response including the IP address and port number of the image capturing apparatus to the playback apparatus. Thus, the playback apparatus transmits a first connection request to the image capturing apparatus according to the IP address and the port number, the first connection request not including the connection identification. The image capturing apparatus confirms that the image capturing apparatus is currently connectable to the apparatus, and confirms that the playback apparatus has not communicated service information with the image capturing apparatus before, based on the first connection request that does not include the connection identifier, whereby the image capturing apparatus generates the connection identifier, and generates a connection response that includes the connection identifier. The image pickup apparatus locally stores the connection identifier, and transmits a connection response including the connection identifier to the playback apparatus so that the playback apparatus stores the connection identifier. Thus, the communication connection between the camera equipment and the playing equipment is realized, and the connection is identified through the connection identification.
Step 402: the first device and the second device establish a heartbeat connection.
After the first device and the second device establish communication connection, the first device and the second device establish heartbeat connection.
The heartbeat connection is that the first equipment sends a heartbeat instruction to the second equipment every preset time, so that the second equipment sends a heartbeat response to the first equipment, and the heartbeat response does not comprise the target service identification. Specifically, every preset time, the first device sends a heartbeat instruction to the second device, and after the second device acquires the heartbeat instruction, the second device feeds back a heartbeat response to the first device. In this way, through the interaction of the heartbeat command and the heartbeat response, the first device and the second device can confirm that the current connection is normal, and the second device is prevented from being connected with other devices to replace the first device, so that the connection between the first device and the second device can be maintained to be normal. In addition, the heartbeat command and the heartbeat response may carry some information, specifically, the heartbeat response carries current state information of the second device, for example, the current second device does not execute the target service, so that the heartbeat response does not include the target service identifier. The target service identifier is used for indicating the state that the second device executes the target service to obtain the target service information.
Step 403: the second device executes the target service to obtain target service information, and generates a heartbeat response including the target service identification.
On the second device, the second device may execute the target service to obtain target service information. The current state of the second device is a state in which the target service is executed to obtain target service information. The second device generates a target service identity to represent the status by the target service identity. The second device generates a heartbeat response including the target traffic identification. The target service identifier is used for indicating the state that the second device executes the target service to obtain the target service information. In the heartbeat connection, the first device sends a heartbeat instruction to the second device every preset time. After receiving the heartbeat instruction, the second device sends a heartbeat response to the first device, and at this time, the heartbeat response includes the target service identifier.
There are various specific ways for the second device to execute the target service, for example, the user controls the second device to trigger the second device to execute the target service. Or the first device triggers the second device to execute the target service.
In a specific example, the step of the second device executing the target service to obtain target service information, and generating a heartbeat response including the target service identifier includes: when the second device acquires the target service triggering instruction sent by the first device, the second device executes the target service to obtain target service information, and generates a heartbeat response comprising the target service identifier.
For example, the target service triggering instruction is a video triggering instruction, and the user controls the playing device, so that the playing device sends the video triggering instruction to the image capturing device, and under the triggering of the video triggering instruction, the image capturing device executes the service of collecting video information to obtain the video information. The image pickup device generates a heartbeat response including a video mark, the video mark is a target service mark, and the video mark represents a service that the image pickup device executes to collect video information so as to obtain a state of the video information. The recording identifier may be recording time or a tag string, which is not particularly limited in the embodiment of the present invention.
Step 404: the second device sends the target service information to the first device, and a heartbeat response including the target service identification.
The second device sends target service information to the first device, and the heartbeat response comprises the target service identifier, so that the first device can apply the target service information to execute target operation, and the first device is informed of the current specific state of the second device through the heartbeat response, specifically, the second device is informed of the state of executing the target service to the first device through the target service identifier to obtain the target service information.
Accordingly, at this time, for the first device, when the first device acquires the target service information sent by the second device, the heartbeat response acquired by the first device includes the target service identifier.
Further, if the first device triggers the second device to execute the target service, when the first device obtains the target service information sent by the second device, the step of obtaining, by the first device, the heartbeat response including the target service identifier specifically includes: the first device sends a target service trigger instruction to the second device, so that the second device executes the target service to obtain target service information, and generates a heartbeat response including the target service identifier, which is specifically described with reference to step 403. The second device then sends the target traffic information to the first device, along with a heartbeat response including the target traffic identification. In this way, the first device may obtain the target service information sent by the second device, and the heartbeat response including the target service identifier.
For example, the image pickup apparatus transmits video information to the playback apparatus, and at the same time, in a period of the heartbeat connection, the playback apparatus transmits a heartbeat instruction to the image pickup apparatus to cause the image pickup apparatus to transmit a heartbeat response to the playback apparatus, at which time the heartbeat response includes a video recording identifier. The video mark represents a state in which the image capturing apparatus performs a service of capturing video information to obtain the video information.
It should be appreciated that in some embodiments of the invention, a heartbeat response is generated by the second device, on which real-time status information of the second device may be recorded. The target service identifier is one of the real-time status information of the second device. A variety of real-time status information may be recorded on the heartbeat response.
Step 405: the first device performs a target operation using the target service information.
After the first device obtains the target service information, the first device may execute the target operation by applying the target service information. Thus, the first device and the second device cooperatively execute the service.
The first device obtains a heartbeat response including the target service identifier, and the first device may obtain the target service identifier from the heartbeat response to perform operations, such as displaying the target service identifier while performing the target operation, or determining whether to perform the target operation using the target service information based on the target service identifier.
For example, after the playback device acquires the video information acquired by the image capturing device, the playback device plays the video information. In some examples, the playback device may also display the video time when the video identifier is the video time.
Optionally, in some embodiments, step 405 specifically includes: when the first device detects that the heartbeat response comprises the target service identifier, the first device applies the target service information to execute the target operation. In other words, the first device performs the target operation using the target traffic information, requiring triggering of the target traffic identification on the heartbeat response.
Optionally, in some embodiments, step 405 specifically includes: the first device applies the target service information and the target service identifier to execute the target operation. For example, the target operates to simultaneously display target traffic information and target traffic identification.
For example, after the image capturing device sends video information and a heartbeat response including a video identifier to the playing device, the playing device detects that the heartbeat response includes the video identifier, so that the service that the image capturing device performs the video information collection is known, and the playing device simultaneously displays the video information and the video identifier on the display screen. Wherein, the record mark is a character string of record time.
Step 406: and after the first equipment and the second equipment are disconnected from the heartbeat, the first equipment and the second equipment reestablish communication connection.
The first device and the second device may disconnect the heartbeat due to unstable network or problems with the devices. After the first device and the second device disconnect the heartbeat, the second device maintains to execute the target service to obtain the target service information, but the second device cannot successfully send the target service information to the first device at this time.
After the first device and the second device disconnect the heartbeat connection, and before the first device and the second device reestablish the heartbeat connection, the first device and the second device reestablish the communication connection. The communication connection means that the first device and the second device allow each other to communicate.
Specifically, at the first device side, the step of reestablishing the communication connection between the first device and the second device specifically includes:
the first device sends a second connection request comprising the connection identifier to the second device, so that the second device generates a connection response when detecting that the locally stored connection identifier is the same as the connection identifier on the second connection request;
the first equipment acquires a connection response sent by the second equipment so as to realize the reestablishment of communication connection between the first equipment and the second equipment.
On the other hand, at the second device side, the step of reestablishing the communication connection between the second device and the first device specifically includes:
the second equipment acquires a second connection request which is sent by the first equipment and comprises a connection identifier;
when the second equipment detects that the locally stored connection identifier is the same as the connection identifier on the second connection request, a connection response is generated;
the second device sends a connection response to the first device to enable the second device to reestablish the communication connection with the first device.
Thus, the communication connection can be identified and recorded by the connection identifier, and the first device and the second device can mutually confirm through the comparison of the connection identifier so as to restore the communication connection.
For example, in the above steps, after the original playing device acquires the video information collected by the image capturing device, the playing device plays the video information. The playing device and the camera device are disconnected with heartbeat connection due to unstable network or problems of the devices, so that the playing device interrupts playing the video information. However, in the process of disconnecting the playback apparatus and the image pickup apparatus from each other, the image pickup apparatus is still executing a service of collecting video information. The playback device and the image capturing device can reestablish the communication connection. Specifically, to restore the connection, the playback device reads the locally recorded connection identifier to generate a second connection request including the connection identifier. The playback apparatus transmits a second connection request including a connection identification to the image pickup apparatus. When the above steps are performed, the image pickup apparatus locally stores the connection identifier. When the image capturing apparatus detects that the locally stored connection identifier is the same as the connection identifier on the second connection request, it indicates that the playback apparatus and the image capturing apparatus have been connected before, and thus the image capturing apparatus generates a connection response. The camera equipment sends a connection response to the playing equipment so as to realize that the playing equipment and the camera equipment reestablish communication connection.
Optionally, the step of disconnecting the heartbeat connection between the first device and the second device specifically includes: if the first device does not acquire the heartbeat response from the second device within the target disconnection time, the first device determines to disconnect the heartbeat from the second device. The target disconnection time is a time period with a preset duration, and the starting time of the target disconnection time is the time when the first equipment sends the heartbeat instruction to the second equipment. In other words, after each time the first device sends a heartbeat command to the second device, in the target disconnection time, the first device does not acquire a heartbeat response from the second device, and then the first device determines to disconnect the heartbeat from the second device. And after the first equipment and the second equipment are disconnected from the heartbeat, the first equipment and the second equipment reestablish communication connection.
Step 407: the first device and the second device reestablish the heartbeat connection.
After the first device and the second device reestablish the communication connection, the second device and the first device reestablish the heartbeat connection. Specifically, every preset time, the first device sends a heartbeat instruction to the second device, and after the second device acquires the heartbeat instruction, the second device feeds back a heartbeat response to the first device. In this way, through the interaction of the heartbeat command and the heartbeat response, the first device and the second device can confirm that the current connection is normal, and the second device is prevented from being connected with other devices to replace the first device, so that the connection between the first device and the second device can be maintained to be normal.
Step 408: the second device sends the target service information to the first device, and a heartbeat response including the target service identification.
The first equipment and the second equipment reestablish the heartbeat connection, so that the second equipment sends a heartbeat response comprising the target service identifier to the first equipment, namely, the first equipment sends a heartbeat instruction to the second equipment every preset time, and the second equipment feeds back the heartbeat response to the first equipment after acquiring the heartbeat instruction. And after the first equipment and the second equipment are disconnected from the heartbeat, the second equipment keeps executing the target service to obtain the target service information, namely the state of the second equipment is always the state of executing the target service to obtain the target service information, so that the heartbeat response comprises the target service identifier.
The second equipment executes the target service to obtain target service information, and after the first equipment and the second equipment reestablish communication connection, the second equipment resumes sending the target service information to the first equipment.
In this way, the second device sends the target service information to the first device, and a heartbeat response including the target service identification, such that the first device re-performs the target operation using the target service information when the first device detects that the heartbeat response includes the target service identification. Reference is made in particular to the detailed description of step 409.
Step 409: when the first device detects that the heartbeat response comprises the target service identifier, the first device applies the target service information acquired from the second device to re-execute the target operation.
The second device sends the target service information to the first device, and a heartbeat response including the target service identification. When the first device detects that the heartbeat response includes the target service identification, the first device may determine that the second device is in a state of executing the target service to obtain target service information, and thus, the first device re-executes the target operation by applying the target service information acquired from the second device. Specifically, under the triggering of the target service identifier, the first device applies the target service information acquired from the second device to re-execute the target operation. Therefore, after the first equipment and the second equipment interrupt communication, the first equipment can quickly resume the execution target operation, and the first equipment and the second equipment can quickly resume the service connection state.
For example, the image pickup apparatus transmits video information to the playback apparatus, and the image pickup apparatus transmits a heartbeat response including a video recording identification to the playback apparatus. When the playing device detects that the heartbeat response comprises the video mark, the playing device determines that the image pickup device is in a state of executing a service for collecting video information so as to obtain the video information, or in a video recording state. Thus, the playing device can resume the playing service quickly by applying the video information acquired from the image pickup device to execute the operation of playing the video information again, thereby realizing the quick recovery of the service connection state of the image pickup device and the playing device.
Optionally, in some embodiments of the present invention, after the first device and the second device disconnect the heartbeat, the method of the embodiment of the present invention further includes: and when the disconnection timeout time is not exceeded and the second device acquires a third connection request sent by the third device, the second device refuses to connect the third device. The disconnection timeout time is a preset duration from each time when the heartbeat instruction is acquired. In other words, after each time the second device acquires the heartbeat command sent by the first device, the second device starts to count the disconnection timeout time.
And when the second device and the first device do not reestablish the heartbeat connection within the disconnection timeout time, and the second device acquires a third connection request sent by the third device after the disconnection timeout time, the second device and the third device establish communication connection. The manner in which the second device and the third device establish the communication connection may refer to the detailed description of step 401, where the first device may be replaced by the third device.
In this way, when the disconnection timeout time is not exceeded, the second device keeps waiting to reestablish the communication connection and the heartbeat connection with the first device, and avoids connecting other devices, thereby ensuring the service recovery of the second device and the first device within a certain time. If the second device and the first device do not reestablish the heartbeat connection within the disconnection timeout period, the second device may connect to the other device such that the second device and the other device can cooperatively perform the service.
It should be appreciated that in embodiments of the present invention, the target off-time and the off-timeout are different times. The target disconnection time is used for determining that the heartbeat connection is disconnected and is mainly used by the first equipment; the disconnection timeout is used to let the second device determine whether to replace the device to be connected. The disconnection timeout time may be longer than the target disconnection time.
It should be understood that in the embodiment of the present invention, there are various implementations of the first device, the second device, the target service information, the target service, and the target operation. The first device is a playing device, the second device is a camera device, the target service information is video information, the target service is to collect the video information, and the target operation is to play the video information, which is just one example. The playing device may be a mobile phone, the image capturing device may be a panoramic camera, and the video information may be panoramic video information.
In summary, in the service connection method according to the embodiment of the present invention, the first device and the second device establish a heartbeat connection, where the heartbeat connection is that the first device sends a heartbeat instruction to the second device every preset time, so that the second device sends a heartbeat response to the first device, and the heartbeat response does not include the target service identifier. The second device executes the target service to obtain target service information, and generates a heartbeat response including a target service identifier, where the target service identifier is used to indicate a state in which the second device executes the target service to obtain the target service information. The second device sends the target service information to the first device, and a heartbeat response including the target service identification. Thus, when the first device acquires the target service information sent by the second device, the heartbeat response acquired by the first device includes the target service identifier. The first device performs a target operation using the target service information. Thereby realizing that the first equipment and the second equipment execute the service cooperatively. When the first equipment and the second equipment are disconnected, the first equipment and the second equipment reestablish the heartbeat connection so that the second equipment sends a heartbeat response comprising the target service identification to the first equipment, wherein the second equipment maintains to execute the target service during the period that the first equipment and the second equipment are disconnected to obtain the target service information. When the first device detects that the heartbeat response comprises the target service identifier, the first device applies the target service information acquired from the second device to re-execute the target operation. Thus, even if the first device and the second device are disconnected, after the first device and the second device are restored to be connected, the first device can re-execute the target operation by using the target service information acquired from the second device, so that the service connection state can be quickly restored.
Fig. 5 is a schematic structural diagram of an electronic device according to another embodiment of the present invention. The electronic device of the embodiment shown in fig. 5 may be used to perform the service connection method of the embodiments shown in fig. 2 and 4.
Referring to fig. 5, an electronic device according to an embodiment of the present invention includes:
the establishing unit 501 is configured to establish a heartbeat connection with the second device, where the heartbeat connection is that the first device sends a heartbeat instruction to the second device every preset time, so that the second device sends a heartbeat response to the first device, and the heartbeat response does not include the target service identifier;
an obtaining unit 502, configured to obtain, when the first device obtains target service information sent by the second device, a heartbeat response including a target service identifier, where the target service identifier is used to indicate a state in which the second device performs a target service to obtain the target service information;
an application unit 503 for executing a target operation by applying the target service information;
the establishing unit 501 is further configured to reestablish a heartbeat connection with the second device after the first device and the second device are disconnected, so that the second device sends a heartbeat response including the target service identifier to the first device, where the second device maintains executing the target service during the period when the first device and the second device are disconnected from the heartbeat, so as to obtain target service information;
A service application unit 504, configured to, when the first device detects that the heartbeat response includes the target service identifier, re-execute the target operation by applying the target service information acquired from the second device;
the first device is an electronic device.
Optionally, the electronic device further includes a communication connection unit 505;
a communication connection unit 505, configured to establish a communication connection with the second device before the first device and the second device establish a heartbeat connection;
the communication connection unit 505 is further configured to reestablish a communication connection with the second device after the first device and the second device disconnect the heartbeat connection and before the first device and the second device reestablish the heartbeat connection.
Optionally, the electronic device further comprises a sending unit 506;
a sending unit 506, configured to send a target service triggering instruction to the second device, so that the second device executes the target service to obtain target service information, and generate a heartbeat response including the target service identifier;
the obtaining unit 502 is further configured to obtain target service information sent by the second device, and a heartbeat response including the target service identifier.
Optionally, the communication connection unit 505 includes a sending module 507, an obtaining module 508, and a recording module 509;
A sending module 507, configured to send a first connection request to the second device, so that the second device generates a connection response including the connection identifier and stores the connection identifier, where the first connection request does not include the connection identifier;
an obtaining module 508, configured to obtain a connection response sent by the second device, so as to establish a communication connection between the first device and the second device;
a recording module 509, configured to record a connection identifier;
the sending module 507 is further configured to send a second connection request including a connection identifier to the second device, so that when the second device detects that the locally stored connection identifier is the same as the connection identifier on the second connection request, a connection response is generated;
the obtaining module 508 is further configured to obtain a connection response sent by the second device, so as to enable the first device and the second device to reestablish the communication connection.
Optionally, the electronic device further comprises a disconnection determining unit 510;
a disconnection determining unit 510, configured to determine that the heartbeat connection is disconnected from the second device if the first device does not acquire the heartbeat response from the second device within the target disconnection time;
the first device is a playing device; the second device is an image pickup device; the target service information is video information; the target service is to collect video information; the target operation is to play video information.
In summary, in the electronic device according to the embodiment of the present invention, the establishing unit 501 establishes a heartbeat connection with the second device, where the heartbeat connection is that the first device sends a heartbeat instruction to the second device every preset time, so that the second device sends a heartbeat response to the first device, and the heartbeat response does not include the target service identifier. When the first device acquires the target service information sent by the second device, the acquiring unit 502 acquires a heartbeat response including a target service identifier, where the target service identifier is used to indicate a state in which the second device executes the target service to obtain the target service information. The application unit 503 performs a target operation by applying the target service information. When the first device and the second device disconnect the heartbeat connection, the establishing unit 501 and the second device reestablish the heartbeat connection, so that the second device sends a heartbeat response including the target service identifier to the first device, where the second device maintains executing the target service during the period when the first device and the second device disconnect the heartbeat connection, so as to obtain the target service information. When the first device detects that the heartbeat response includes the target service identification, the service application unit 504 re-performs the target operation by applying the target service information acquired from the second device. The first device is an electronic device. Thus, even if the first device and the second device are disconnected, after the first device and the second device are restored to be connected, the first device can re-execute the target operation by using the target service information acquired from the second device, so that the service connection state can be quickly restored.
Fig. 6 is a schematic structural diagram of an electronic device according to another embodiment of the present invention. The electronic device of the embodiment shown in fig. 6 may be used to perform the service connection method of the embodiments shown in fig. 3 and 4.
Referring to fig. 6, an electronic device according to an embodiment of the present invention includes:
the establishing unit 601 is configured to establish a heartbeat connection with the first device, where the heartbeat connection is that the first device sends a heartbeat instruction to the second device every preset time, so that the second device sends a heartbeat response to the first device, and the heartbeat response does not include the target service identifier;
an execution unit 602, configured to execute a target service to obtain target service information, and generate a heartbeat response including a target service identifier, where the target service identifier is used to indicate a state in which the second device executes the target service to obtain the target service information;
a sending unit 603, configured to send target service information to the first device, and a heartbeat response including the target service identifier, so that the first device applies the target service information to perform a target operation;
the execution unit 602 is further configured to maintain executing the target service after the first device and the second device disconnect the heartbeat connection, so as to obtain target service information;
The establishing unit 601 is further configured to reestablish a heartbeat connection with the first device;
the sending unit 603 is further configured to send the target service information to the first device, and a heartbeat response including the target service identifier, so that when the first device detects that the heartbeat response includes the target service identifier, the first device applies the target service information to re-perform the target operation;
the second device is an electronic device.
Optionally, the electronic device further comprises a communication connection unit 604;
a communication connection unit 604, configured to establish a communication connection with the first device before the second device establishes a heartbeat connection with the first device;
the communication connection unit 604 is further configured to reestablish a communication connection with the first device after the first device and the second device disconnect the heartbeat connection and before the second device and the first device reestablish the heartbeat connection.
Optionally, the executing unit 602 is further configured to execute the target service when the second device obtains the target service trigger instruction sent by the first device, so as to obtain target service information, and generate a heartbeat response including the target service identifier;
wherein the first device is a playing device; the second device is an image pickup device; the target service information is video information; the target service is to collect video information; the target operation is to play video information.
Optionally, the communication connection unit 604 includes a generating module 605, a sending module 606, an obtaining module 607, and a storage module 608;
a generating module 605, configured to generate, when the second device obtains a first connection request that does not include a connection identifier and is sent by the first device, a connection response that includes the connection identifier;
a storage module 608 for storing a connection identifier;
a sending module 606, configured to send a connection response to the first device, so as to enable the second device to establish a communication connection with the first device, and enable the first device to record a connection identifier;
an obtaining module 607, configured to obtain a second connection request sent by the first device and including a connection identifier;
the generating module 605 is further configured to generate a connection response when detecting that the locally stored connection identifier is the same as the connection identifier on the second connection request;
the sending module 606 is further configured to send a connection response to the first device, so as to enable the second device to reestablish the communication connection with the first device.
Optionally, the communication connection unit 604 is further configured to reject connection to the third device when the disconnection timeout time is not exceeded after the first device and the second device disconnect the heartbeat, and the second device obtains the third connection request sent by the third device, where the disconnection timeout time is a preset duration from when the heartbeat command is obtained each time; and when the second device and the first device do not reestablish the heartbeat connection within the disconnection timeout period, and the second device acquires a third connection request sent by the third device after the disconnection timeout period, establishing communication connection with the third device.
In summary, in the electronic device according to the embodiment of the present invention, the establishing unit 601 establishes a heartbeat connection with the first device, where the heartbeat connection is that the first device sends a heartbeat instruction to the second device every preset time, so that the second device sends a heartbeat response to the first device, and the heartbeat response does not include the target service identifier. The execution unit 602 executes the target service to obtain target service information, and generates a heartbeat response including a target service identifier, where the target service identifier is used to indicate a state in which the second device executes the target service to obtain the target service information. The transmitting unit 603 transmits the target service information to the first device, and a heartbeat response including the target service identifier, so that the first device performs the target operation using the target service information. After the first device and the second device are disconnected from each other, the execution unit 602 maintains executing the target service to obtain the target service information. The establishing unit 601 and the first device reestablish the heartbeat connection. The transmitting unit 603 transmits the target service information and the heartbeat response including the target service identifier to the first device, so that the first device re-performs the target operation by applying the target service information when detecting that the heartbeat response includes the target service identifier. The second device is an electronic device. Thus, even if the first device and the second device are disconnected, after the first device and the second device are restored to be connected, the second device sends the target service information to the first device, and the first device re-executes the target operation by applying the target service information, so that the service connection state is quickly restored.
It will be clear to those skilled in the art that, for convenience and brevity of description, specific working procedures of the above-described systems, apparatuses and units may refer to corresponding procedures in the foregoing method embodiments, which are not repeated herein.
In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices, and methods may be implemented in other manners. For example, the apparatus embodiments described above are merely illustrative, e.g., the division of the units is merely a logical function division, and there may be additional divisions when actually implemented, e.g., multiple units or components may be combined or integrated into another system, or some features may be omitted or not performed. Alternatively, the coupling or direct coupling or communication connection shown or discussed with each other may be an indirect coupling or communication connection via some interfaces, devices or units, which may be in electrical, mechanical or other form.
The units described as separate units may or may not be physically separate, and units shown as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
In addition, each functional unit in the embodiments of the present invention may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit. The integrated units may be implemented in hardware or in software functional units.
The integrated units, if implemented in the form of software functional units and sold or used as stand-alone products, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present invention may be embodied essentially or in part or all of the technical solution or in part in the form of a software product stored in a storage medium, including instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a random access Memory (RAM, random Access Memory), a magnetic disk, or an optical disk, or other various media capable of storing program codes.
The above embodiments are only for illustrating the technical solution of the present invention, and not for limiting the same; although the invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical scheme described in the foregoing embodiments can be modified or some technical features thereof can be replaced by equivalents; such modifications and substitutions do not depart from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims (12)

1. A service connection method, comprising:
the method comprises the steps that a first device and a second device establish heartbeat connection, wherein the heartbeat connection is that a heartbeat instruction is sent to the second device by the first device every preset time, so that when the second device does not execute target service, a heartbeat response which does not comprise target service identification is sent to the first device by the second device;
if the first device acquires the target service information sent by the second device, the first device acquires a heartbeat response comprising the target service identifier, wherein the target service identifier is used for indicating the state that the second device executes the target service to obtain the target service information;
The first equipment applies the target service information to execute target operation;
when the first device and the second device disconnect the heartbeat connection, the first device and the second device reestablish the heartbeat connection so that the second device sends a heartbeat response comprising the target service identifier to the first device, wherein the second device keeps executing the target service during the period that the first device and the second device disconnect the heartbeat connection so as to obtain the target service information;
and when the first equipment detects that the heartbeat response sent by the second equipment after the heartbeat connection is reestablished comprises the target service identifier, the first equipment re-executes the target operation by applying the target service information acquired from the second equipment.
2. The service connection method according to claim 1, wherein before the first device and the second device establish the heartbeat connection, the method further comprises:
the first equipment and the second equipment establish communication connection;
after the first device and the second device disconnect the heartbeat connection and before the first device and the second device reestablish the heartbeat connection, the method further includes: the first device and the second device reestablish a communication connection.
3. The service connection method according to claim 1, wherein if the first device obtains the target service information sent by the second device, the first device obtains a heartbeat response including the target service identifier, including:
the first device sends a target service triggering instruction to the second device so that the second device executes the target service to obtain the target service information, and generates a heartbeat response comprising the target service identifier;
the first device obtains the target service information sent by the second device and the heartbeat response comprising the target service identifier.
4. The service connection method according to claim 2, wherein the first device and the second device establish a communication connection, comprising:
the method comprises the steps that a first device sends a first connection request to a second device, so that the second device generates a connection response comprising a connection identifier and stores the connection identifier, wherein the first connection request does not comprise the connection identifier;
the first equipment acquires the connection response sent by the second equipment so as to establish communication connection between the first equipment and the second equipment;
The first equipment records the connection identifier;
the first device and the second device reestablish communication connection, including: the first device sends a second connection request comprising the connection identifier to the second device, so that the second device generates the connection response when detecting that the connection identifier stored locally is the same as the connection identifier on the second connection request;
and the first equipment acquires the connection response sent by the second equipment so as to realize the reestablishment of communication connection between the first equipment and the second equipment.
5. The service connection method according to claim 1, wherein the first device and the second device disconnect the heartbeat connection, comprising:
if the first device does not acquire the heartbeat response from the second device within the target disconnection time, the first device determines to disconnect the heartbeat connection with the second device; the first device is a playing device;
the second device is an image pickup device;
the target service information is video information;
the target service is to collect the video information;
the target operates to play the video information.
6. A service connection method, comprising:
the method comprises the steps that a heartbeat connection is established between second equipment and first equipment, wherein the heartbeat connection is that a heartbeat instruction is sent to the second equipment by the first equipment every preset time, so that when target service is not executed by the second equipment, a heartbeat response which does not comprise target service identification is sent to the first equipment by the second equipment;
the second device executes a target service to obtain target service information, and generates a heartbeat response comprising a target service identifier, wherein the target service identifier is used for indicating a state that the second device executes the target service to obtain the target service information;
the second device sends the target service information to the first device, and a heartbeat response comprising the target service identifier, so that the first device executes target operation by applying the target service information;
after the first device and the second device disconnect the heartbeat connection, the second device maintains to execute the target service so as to obtain the target service information;
the second device and the first device reestablish a heartbeat connection;
The second device sends the target service information to the first device, and the heartbeat response comprising the target service identifier, so that when the first device detects that the heartbeat response sent by the second device after reestablishing the heartbeat connection comprises the target service identifier, the first device uses the target service information to re-execute the target operation.
7. The service connection method according to claim 6, wherein before the second device and the first device establish the heartbeat connection, the method further comprises:
the second equipment and the first equipment establish communication connection;
after the first device and the second device disconnect the heartbeat connection and before the second device and the first device reestablish the heartbeat connection, the method further includes: the second device reestablishes communication connection with the first device.
8. The service connection method according to claim 6, wherein the second device executes a target service to obtain target service information, and generating a heartbeat response including the target service identifier, includes:
when the second device acquires a target service triggering instruction sent by the first device, the second device executes target service to obtain target service information, and generates a heartbeat response comprising the target service identifier;
Wherein the first device is a playing device;
the second device is an image pickup device;
the target service information is video information; the target service is to collect the video information;
the target operates to play the video information.
9. The service connection method according to claim 7, wherein the second device and the first device establish a communication connection, comprising:
when a second device obtains a first connection request which is sent by a first device and does not comprise a connection identifier, the second device generates a connection response comprising the connection identifier and stores the connection identifier;
the second device sends the connection response to the first device so as to enable the second device to establish communication connection with the first device, and enable the first device to record the connection identification;
the second device reestablishing a communication connection with the first device, comprising:
the second device obtains a second connection request which is sent by the first device and comprises the connection identifier;
generating the connection response when the second device detects that the locally stored connection identifier is the same as the connection identifier on the second connection request;
And the second equipment sends the connection response to the first equipment so as to realize the reestablishment of communication connection between the second equipment and the first equipment.
10. The service connection method according to claim 9, wherein after the first device and the second device disconnect the heartbeat connection, the method further comprises:
when the disconnection timeout time is not exceeded and the second device acquires a third connection request sent by a third device, the second device refuses to connect the third device, wherein the disconnection timeout time is a preset duration from each time when the heartbeat instruction is acquired;
and when the second device and the first device do not reestablish the heartbeat connection within the disconnection timeout time, and the second device acquires the third connection request sent by the third device after the disconnection timeout time, the second device and the third device establish communication connection.
11. An electronic device, comprising:
the device comprises an establishing unit, a first device and a second device, wherein the establishing unit is used for establishing heartbeat connection with the second device, the heartbeat connection is that a first device sends a heartbeat instruction to the second device every preset time, so that when the second device does not execute a target service, the second device sends a heartbeat response which does not comprise a target service identifier to the first device;
The system comprises an acquisition unit, a first device and a second device, wherein the acquisition unit is used for acquiring a heartbeat response comprising a target service identifier if the first device acquires target service information sent by the second device, and the target service identifier is used for indicating the state that the second device executes target service to acquire the target service information;
the application unit is used for applying the target service information to execute target operation;
the establishing unit is further configured to reestablish a heartbeat connection with the second device after the first device and the second device disconnect the heartbeat connection, so that the second device sends a heartbeat response including the target service identifier to the first device, where the second device maintains executing the target service during the period when the first device and the second device disconnect the heartbeat connection, so as to obtain the target service information;
a service application unit, configured to, when the first device detects that the heartbeat response sent by the second device after reestablishing the heartbeat connection includes the target service identifier, re-execute the target operation by applying the target service information acquired from the second device; the first device is the electronic device.
12. An electronic device, comprising:
the system comprises an establishing unit, a first device and a second device, wherein the establishing unit is used for establishing heartbeat connection with the first device, the heartbeat connection is that the first device sends a heartbeat instruction to the second device every preset time, so that when the second device does not execute a target service, the second device sends a heartbeat response which does not comprise a target service identifier to the first device;
the system comprises an execution unit, a target service identification unit and a processing unit, wherein the execution unit is used for executing target service to obtain target service information and generating a heartbeat response comprising the target service identification, and the target service identification is used for indicating the state that the second equipment executes the target service to obtain the target service information;
a sending unit, configured to send the target service information to the first device, and a heartbeat response including the target service identifier, so that the first device performs a target operation by applying the target service information;
the execution unit is further configured to maintain execution of the target service after the first device and the second device disconnect the heartbeat connection, so as to obtain the target service information;
the establishing unit is further used for reestablishing heartbeat connection with the first device; the sending unit is further configured to send the target service information to the first device, and a heartbeat response including the target service identifier, so that when the first device detects that the heartbeat response sent by the second device after reestablishing the heartbeat connection includes the target service identifier, the first device re-executes the target operation by applying the target service information;
The second device is the electronic device.
CN202111076617.8A 2021-09-14 2021-09-14 Service connection method and electronic equipment Active CN113746934B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111076617.8A CN113746934B (en) 2021-09-14 2021-09-14 Service connection method and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111076617.8A CN113746934B (en) 2021-09-14 2021-09-14 Service connection method and electronic equipment

Publications (2)

Publication Number Publication Date
CN113746934A CN113746934A (en) 2021-12-03
CN113746934B true CN113746934B (en) 2023-11-14

Family

ID=78738756

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111076617.8A Active CN113746934B (en) 2021-09-14 2021-09-14 Service connection method and electronic equipment

Country Status (1)

Country Link
CN (1) CN113746934B (en)

Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2001077844A1 (en) * 2000-04-10 2001-10-18 Fujitsu Limited Information processing system and method, and server
CN102131152A (en) * 2010-01-15 2011-07-20 中兴通讯股份有限公司 Method and system for maintaining continuity of instant message service
CN106034261A (en) * 2015-03-17 2016-10-19 北京视联动力国际信息技术有限公司 Visual networking service processing method and apparatus thereof
CN109391495A (en) * 2017-08-10 2019-02-26 阿里巴巴集团控股有限公司 Send and receive method, apparatus, computer-readable medium and the electronic equipment of heartbeat message
CN111131473A (en) * 2019-12-27 2020-05-08 中国联合网络通信集团有限公司 Network parameter transmission method and device
CN111200521A (en) * 2019-12-27 2020-05-26 视联动力信息技术股份有限公司 Video networking service recovery method, server, electronic equipment and storage medium
CN111200538A (en) * 2019-12-25 2020-05-26 苏宁云计算有限公司 Monitoring method and device for intelligent equipment
WO2020165866A1 (en) * 2019-02-14 2020-08-20 Telefonaktiebolaget Lm Ericsson (Publ) Controlling the reporting of early measurements and connected mode measurements based on traffic volume and other conditions
CN113038158A (en) * 2021-03-09 2021-06-25 北京高途云集教育科技有限公司 Object display method and device based on live broadcast, electronic equipment and medium

Patent Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2001077844A1 (en) * 2000-04-10 2001-10-18 Fujitsu Limited Information processing system and method, and server
CN102131152A (en) * 2010-01-15 2011-07-20 中兴通讯股份有限公司 Method and system for maintaining continuity of instant message service
CN106034261A (en) * 2015-03-17 2016-10-19 北京视联动力国际信息技术有限公司 Visual networking service processing method and apparatus thereof
CN109391495A (en) * 2017-08-10 2019-02-26 阿里巴巴集团控股有限公司 Send and receive method, apparatus, computer-readable medium and the electronic equipment of heartbeat message
WO2020165866A1 (en) * 2019-02-14 2020-08-20 Telefonaktiebolaget Lm Ericsson (Publ) Controlling the reporting of early measurements and connected mode measurements based on traffic volume and other conditions
CN111200538A (en) * 2019-12-25 2020-05-26 苏宁云计算有限公司 Monitoring method and device for intelligent equipment
CN111131473A (en) * 2019-12-27 2020-05-08 中国联合网络通信集团有限公司 Network parameter transmission method and device
CN111200521A (en) * 2019-12-27 2020-05-26 视联动力信息技术股份有限公司 Video networking service recovery method, server, electronic equipment and storage medium
CN113038158A (en) * 2021-03-09 2021-06-25 北京高途云集教育科技有限公司 Object display method and device based on live broadcast, electronic equipment and medium

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
Hourgkass:An infrastructure for connecting sersor networks and applications;Jess Shneidman et al.;《SEMANTIC SCHOLAR》;全文 *
移动网络中业务流程执行环境关键技术的研究与实现;张同光;《中国博士学位论文全文数据库》;全文 *

Also Published As

Publication number Publication date
CN113746934A (en) 2021-12-03

Similar Documents

Publication Publication Date Title
US9973675B2 (en) Transmission apparatus, reception apparatus, communication system, and recording medium
CN111427527B (en) Screen projection method, device, equipment and computer readable storage medium
CN112738540B (en) Multi-device live broadcast switching method, device, system, electronic device and readable storage medium
CN110620889B (en) Video monitoring system, network hard disk video recorder and data transmission method
US9706170B2 (en) Communication apparatus, communication system, and communication management system
US20240179372A1 (en) Method and System for Monitoring Playing of Screen Device, and Storage Medium
CN112260895A (en) Data transmission method and device and processor
CN103596063B (en) Terminal, television, multi-screen interaction system and method for setting screen capture parameters
CN111431964B (en) Message synchronous processing method, device and storage medium
CN112218388A (en) Method and device for reconnection of broken network
CN104853234A (en) Data processing method, system thereof and mobile terminal
CN113746934B (en) Service connection method and electronic equipment
KR101701221B1 (en) Apparatus and method for receiving the streaming data in portable terminal
CN112702403B (en) Intelligent service connection method based on re-networking and communication module
CN107835449B (en) Method for realizing multi-terminal synchronous screen connection based on network on Android platform
US9485458B2 (en) Data processing method and device
CN103051484B (en) Session service processing method, system and Session Border Controll
CN110933775A (en) Method and device for establishing signal connection and electronic equipment
CN113645103B (en) Method and device for detecting communication link abnormity between video monitoring platform and front-end equipment
EP3065445B1 (en) Method, cse, and system for transmitting m2m application request
CN114793291B (en) IOS multi-device real-time screen projection method, system, computer device and storage medium
CN107071038B (en) Method and device for transmitting multimedia data
CN105430423A (en) Video backup method, device and system
CN111107296B (en) Audio data acquisition method and device, electronic equipment and readable storage medium
CN110890989A (en) Channel connection method and device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
CB02 Change of applicant information
CB02 Change of applicant information

Address after: Building 4D, Gongyanhui Science and Technology Industrial Park, No. 160, Xihu West Road, Wujin National High and New Technology Industrial Development Zone, Changzhou City, Jiangsu Province, 213166

Applicant after: Pi Technology (Changzhou) Co.,Ltd.

Address before: 518109 1221, 12 / F, book building, Shenzhen newspaper group, Qinghu community, Longhua street, Longhua District, Shenzhen City, Guangdong Province

Applicant before: SHENZHEN PISOFTTECH TECHNOLOGY Co.,Ltd.

GR01 Patent grant
GR01 Patent grant