Detailed Description
In order to make the objects, technical solutions and advantages of the present invention clearer, the present invention will be described in further detail with reference to the accompanying drawings, and it is apparent that the described embodiments are only a part of the embodiments of the present invention, not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The terminology used in the embodiments of the invention is for the purpose of describing particular embodiments only and is not intended to be limiting of the invention. As used in the examples of the present invention and the appended claims, the singular forms "a", "an", and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise, and "a plurality" typically includes at least two.
It should be understood that the term "and/or" as used herein is merely one type of association that describes an associated object, meaning that three relationships may exist, e.g., a and/or B may mean: a exists alone, A and B exist simultaneously, and B exists alone. In addition, the character "/" herein generally indicates that the former and latter related objects are in an "or" relationship.
It should be understood that although the terms first, second, third, etc. may be used to describe … … in embodiments of the present invention, these … … should not be limited to these terms. These terms are used only to distinguish … …. For example, the first … … can also be referred to as the second … … and similarly the second … … can also be referred to as the first … … without departing from the scope of embodiments of the present invention.
The words "if", as used herein, may be interpreted as "at … …" or "at … …" or "in response to a determination" or "in response to a detection", depending on the context. Similarly, the phrases "if determined" or "if detected (a stated condition or event)" may be interpreted as "when determined" or "in response to a determination" or "when detected (a stated condition or event)" or "in response to a detection (a stated condition or event)", depending on the context.
It is also noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that an article or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such article or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in the article or device in which the element is included.
Alternative embodiments of the present invention are described in detail below with reference to the accompanying drawings.
Example 1
The embodiment provides a method for processing packet loss of an electronic whiteboard based on a state machine, which is applied to a terminal device, where the terminal device may be: a PC (Personal Computer), a smart phone, a tablet Computer, or the like, and the specific type of the terminal device is not specifically limited in this embodiment. Further, the method may be applied to online education-like clients, such as 51 talk. Specifically, as shown in fig. 1, the method is applied to a client, and comprises the following steps:
s11, receiving a data packet sent by the server in real time, and locally recording the data packet information, wherein the data packet information comprises whiteboard drawing data and the data packet ID, and the data packet ID is generated according to a monotone increasing sequence;
the client comprises a teacher end and a student end, the teacher end can directly communicate with the server end through an Http request after logging in, and the student end establishes a long connection with the server end to communicate after logging in, so that synchronous display of whiteboard data is realized. In the specific implementation process, after a teacher logs in a teacher end, the teacher selects a classroom and starts an electronic whiteboard, and a visual operation interface appears, wherein the interface comprises an electronic whiteboard area, an operability toolbar and other areas. The teacher end can draw in the electronic whiteboard region through the terminal equipment, such as illustration and equation writing.
In the process of drawing the whiteboard by the teacher, the teacher continuously collects whiteboard drawing data of the teacher, packages the whiteboard drawing data into a data packet in real time, and uniquely identifies the data packet, namely generates a data packet ID. Here, sequence identification is performed for each packet based on the packet generation time sequence and a monotonically increasing sequence. Wherein the monotonically increasing sequence is that each object in the sequence is greater than or equal to the previous object; if each object is strictly larger than the previous object, the sequence is strictly (monotonically) increasing, for example, the ID of the first generated packet is 1, the ID of the second generated packet is 2, the ID of the third generated packet is 3, and so on, which are strictly increasing in sequence. Preferably, the packet ID is strictly monotonically increasing starting from 1.
After a data packet is generated, a teacher side uploads the data packet to a server side, and the server side records the maximum data packet ID of the current electronic whiteboard every time the server side receives one data packet. It can be understood that, each time the server receives a packet, the server updates the recorded maximum packet ID to the current latest packet ID. For example, if the received packet ID of the server is 4 and the maximum packet ID recorded by the server is 3, the packet ID recorded by the server is updated to the value of 4.
The maximum packet ID is the ID of the currently newly generated packet, and since the packet IDs are serialized from the minimum value according to a monotonically increasing sequence, the currently newly generated packet ID is always the largest as compared to the previously generated packet IDs. Of course, the packet ID is not limited to be monotonically increased from the value 1, and may be arbitrarily defined according to actual needs.
The method comprises the steps that a student end needs to acquire white board data in real time and synchronizes with a teacher end, so that the server end directly sends the white board drawing data to the student end after receiving the white board drawing data of the teacher end; each packet ID is also pushed to the student side. The student end can record locally every time the student end receives a data packet, so that the follow-up packet loss judgment is facilitated; and meanwhile, the whiteboard drawing data in the data packet is called out for drawing, so that the student end can synchronously master the blackboard writing by the teacher.
S12, comparing all the data packet IDs recorded locally with heartbeat packets sent by the server side, and judging whether the data packets are missing or not, wherein the heartbeat packets carry the current maximum data packet ID;
in a specific implementation process, the server side can actively send a heartbeat packet to the student side every other fixed time so as to tell the student side that the electronic whiteboard is in the current state at the teacher side. Wherein, the fixed time is defined according to actual needs, and is not specifically limited herein. And when the student end receives a heartbeat packet, the heartbeat packet is compared with the data packet recorded locally to judge whether the data packet is missing or not.
Specifically, the comparing all the data packet IDs recorded locally with the heartbeat packet sent by the server to determine whether a data packet is missing includes:
sequencing each data packet ID of the local record; and finding the missing data packet ID in the numerical range from the first data packet ID to the current maximum data packet ID.
Wherein the first packet ID refers to an initial ID value when monotonically increasing. For example, the monotonic increase starts from 1, if the packet IDs 2, 4, and 5 are recorded locally, and the current maximum packet ID recorded by the server is 7, then it can be determined that three pieces of packet information with IDs 1, 3, and 6 are lost locally within the range of 1 to 7.
The method comprises the steps that the principle of a state machine is utilized, the current latest whiteboard state (data packet ID representation) of a teacher end is synchronized to each student end through a heartbeat packet, and the student end judges whether whiteboard data loss occurs locally or no current whiteboard data exists locally by comparing the whiteboard state in the state machine with a locally stored whiteboard.
And S13, if the data packet is missing locally, triggering packet loss processing logic.
As an optional embodiment, the triggering packet loss processing logic if a data packet is locally missing includes:
if the number of the locally missing data packets is less than a threshold value, triggering a packet supplementing logic; or,
and if the number of the locally missing data packets is larger than the threshold value, triggering a white filling board logic. Wherein the threshold is artificially defined according to actual requirements. It is understood that, in this step, it is mainly determined whether to perform padding (pulling partial whiteboard data) or padding (pulling all data of the current whiteboard) according to the amount of missing whiteboard data determined in step S12.
In a specific implementation process, referring to fig. 2, if the number of the locally missing data packets is smaller than a threshold, the triggering packet-complementing logic includes:
s131, sending a packet supplementing request to the server, wherein the packet supplementing request carries a data packet ID array of a missing data packet; wherein, the package supplementing request is an Http request.
S132, receiving the missing data packet information returned by the server and locally recording the missing data packet information; specifically, the student end records the data packet information returned by the packet supplementing at the local so as to judge the packet loss next time.
And S133, calling whiteboard drawing data in the data packet information, and drawing on the electronic whiteboard.
As another alternative, referring to fig. 3, if the number of locally missing packets is greater than the threshold, the trigger padding board logic includes:
s134, sending a white board supplementing request to the server, wherein the white board supplementing request carries the current electronic whiteboard ID; and the whiteboard supplementing request is an Http request. Specifically, each time the teacher end switches the electronic whiteboard, the teacher end automatically identifies each electronic whiteboard, that is, generates an electronic whiteboard ID. That is, each electronic whiteboard will have a unique corresponding ID.
And S135, receiving all current data packet information of the electronic whiteboard returned by the server and locally recording the current data packet information. Specifically, the server finds the specified whiteboard data according to the electronic whiteboard ID, acquires all data packet information under the electronic whiteboard, and sends the data packet information to the student side.
And S136, calling whiteboard drawing data in all the data packet information and drawing on the electronic whiteboard. In this step, the student end redraws all drawing data of the electronic whiteboard ID.
Finally, the electronic whiteboard packet loss processing method based on the state machine provided by the embodiment of the invention utilizes the state machine mode to synchronize the whiteboard state of the teacher end at the student end, and the state machine only needs to carry the maximum data packet ID of the current whiteboard; after receiving the state machine information, the student end only needs to compare all the data packet IDs recorded locally with the current maximum data packet ID information to judge whether data packet loss exists or not and which data packets are lost, so that the complexity of judging the whiteboard data loss can be reduced; all current data of the whiteboard do not need to be transmitted, so that the cost of data transmission can be further reduced.
Example 2
Referring to fig. 4, an embodiment of the present invention provides a system 400 for processing packet loss of an electronic whiteboard based on a state machine, where the system 400 may be applied to a terminal device, where the terminal device may be: a PC (Personal Computer), a smart phone, a tablet Computer, or the like, and the specific type of the terminal device is not specifically limited in this embodiment. Further, the method may be applied to online education-like clients, such as 51 talk. Specifically, the system 400 includes: a receiving module 410, a determining module 420 and a processing module 430.
The receiving module 410 is configured to receive a data packet sent by the server in real time, and locally record the data packet information, where the data packet information includes whiteboard drawing data and the data packet ID, and the data packet ID is generated according to a monotonically increasing sequence;
the client side comprises a teacher side and a student side, the teacher can directly communicate with the server side through an Http request after logging in the teacher side, and the student can establish a long connection with the server side to communicate after logging in the student side, so that synchronous display of whiteboard data is achieved. In the specific implementation process, after a teacher logs in a teacher end, the teacher selects a classroom and starts an electronic whiteboard, and a visual operation interface appears, wherein the interface comprises an electronic whiteboard area, an operability toolbar and other areas. The teacher end can draw in the electronic whiteboard region through the terminal equipment, such as illustration and equation writing.
In the process of drawing the whiteboard by the teacher, the teacher continuously collects whiteboard drawing data of the teacher, packages the whiteboard drawing data into a data packet in real time, and uniquely identifies the data packet, namely generates a data packet ID. Here, the teacher end performs sequence identification on each data packet according to the data packet generation time sequence and the monotonically increasing sequence. Wherein the monotonically increasing sequence is that each object in the sequence is greater than or equal to the previous object; if each object is strictly larger than the previous object, the sequence is strictly (monotonically) increasing, for example, the ID of the first generated packet is 1, the ID of the second generated packet is 2, the ID of the third generated packet is 3, and so on, which are strictly increasing in sequence. Preferably, the packet ID is strictly monotonically increasing starting from 1.
And after the data packet is generated, the teacher side uploads the data packet to the server side. And the server records the maximum data packet ID of the current electronic whiteboard when receiving one data packet. It can be understood that, each time the server receives a packet, the server updates the recorded maximum packet ID to the current latest packet ID. For example, if the received packet ID of the server is 4 and the maximum packet ID recorded by the server is 3, the packet ID recorded by the server is updated to the value of 4.
The maximum packet ID is the ID of the currently newly generated packet, and since the packet IDs are serialized from the minimum value according to a monotonically increasing sequence, the currently newly generated packet ID is always the largest as compared to the previously generated packet IDs. Of course, the packet ID is not limited to be monotonically increased from the value 1, and may be arbitrarily defined according to actual needs.
The method comprises the steps that a student end needs to acquire white board data in real time and synchronizes with a teacher end, so that the server end directly sends the white board drawing data to the student end after receiving the white board drawing data of the teacher end; each packet ID is also sent to the student. The receiving module 410 locally records each data packet received, so as to facilitate subsequent packet loss judgment; and meanwhile, the whiteboard drawing data in the data packet is called out for drawing, so that the student end can synchronously master the blackboard writing by the teacher.
The determining module 420 is configured to compare all the locally recorded IDs of the data packets with a heartbeat packet sent by the server, and determine whether a data packet is missing, where the heartbeat packet carries a current maximum data packet ID;
in a specific implementation process, the server side can actively send a heartbeat packet to the student side at regular intervals so as to inform the student side of the current electronic whiteboard state. Wherein, the fixed time is defined according to actual needs, and is not specifically limited herein. When the student receives a heartbeat packet, the judging module 420 compares the heartbeat packet with a locally recorded data packet to judge whether the data packet is missing.
Specifically, the determining module 420 is configured to:
sequencing each data packet ID of the local record; and finding the missing data packet ID in the numerical range from the first data packet ID to the current maximum data packet ID.
Wherein the first packet ID refers to an initial ID value when monotonically increasing. For example, if the monotonic increment is from 1, the local recorded packet IDs are 2, 4, and 5, and the server recorded the current maximum packet ID is 7, the determining module 420 may determine that three packet information with IDs 1, 3, and 6 are lost locally within a range from 1 to 7.
The judging module 420 synchronizes the current latest whiteboard state (data packet ID representation) of the teacher end to each student end through the heartbeat packet by using the principle of the state machine, and the student end judges whether the whiteboard data is lost locally or no current whiteboard data exists by comparing the whiteboard state in the state machine with locally stored whiteboard data.
The processing module 430 is configured to trigger a packet loss processing logic if a data packet is locally missing.
As an optional embodiment, the processing module 430 is specifically configured to:
if the number of the locally missing data packets is less than a threshold value, triggering a packet supplementing logic; or if the number of the locally missing data packets is larger than the threshold value, triggering the white filling board logic.
Wherein the threshold is artificially defined according to actual requirements. It can be understood that the processing module 430 mainly determines to perform padding, that is, to pull part of the whiteboard data, according to the amount of the missing whiteboard data determined by the determining module 420; or the whiteboard is compensated, namely all data of the current whiteboard are pulled.
In a specific implementation process, the processing module 430 is specifically configured to:
sending a packet supplementing request to the server, wherein the packet supplementing request carries a data packet ID array of a missing data packet; receiving the missing data packet information returned by the server and locally recording the missing data packet information; and calling whiteboard drawing data in the data packet information, and drawing on the electronic whiteboard. Wherein, the package supplementing request is an Http request. And the student end records the data packet information returned by the packet supplementing at the local so as to judge the packet loss at the next time.
As another optional embodiment, the processing module 430 is specifically configured to:
sending a white board supplementing request to the server, wherein the white board supplementing request carries the current electronic whiteboard ID; receiving all current data packet information of the electronic whiteboard returned by the server and locally recording the current data packet information; and calling whiteboard drawing data in all the data packet information and drawing on the electronic whiteboard.
And the whiteboard supplementing request is an Http request. Specifically, each time the electronic whiteboard is switched, the teacher end automatically identifies each electronic whiteboard, that is, generates an electronic whiteboard ID. That is, each electronic whiteboard will have a unique corresponding ID. Specifically, the server finds the specified whiteboard data according to the electronic whiteboard ID, acquires all data packet information under the electronic whiteboard, and sends the data packet information to the student side. The processing module 430 redraws all data included in the electronic whiteboard ID.
Finally, the state machine-based electronic whiteboard packet loss processing system 400 provided by the embodiment of the present invention synchronizes the whiteboard state of the teacher side at the student side by using the state machine mode, and the state machine only needs to carry the maximum data packet ID of the current whiteboard; after receiving the state machine information, the student end only needs to compare all the data packet IDs recorded locally with the current maximum data packet ID information to judge whether data packet loss exists or not and which data packets are lost, so that the complexity of judging the whiteboard data loss can be reduced; all current data of the whiteboard do not need to be transmitted, so that the cost of data transmission can be further reduced.
Example 3
The embodiment of the present disclosure provides a non-volatile computer storage medium, where the computer storage medium stores computer-executable instructions, and the computer-executable instructions may execute the method for processing packet loss of an electronic whiteboard based on a state machine in any method embodiment.
Example 4
The embodiment provides an electronic device, which is used for a state machine-based electronic whiteboard packet loss processing method, and the electronic device includes: at least one processor; and a memory communicatively coupled to the at least one processor; wherein,
the memory stores instructions executable by the one processor to cause the at least one processor to:
receiving a data packet sent by a server in real time, and locally recording data packet information, wherein the data packet information comprises whiteboard drawing data and a data packet ID, and the data packet ID is generated according to a monotone increasing sequence;
comparing all the data packet IDs recorded locally with heartbeat packets sent by the server side, and judging whether the data packets are missing or not, wherein the heartbeat packets carry the current maximum data packet IDs;
and if the data packet is missing locally, triggering packet loss processing logic.
Example 5
Referring now to FIG. 5, shown is a schematic diagram of an electronic device suitable for use in implementing embodiments of the present disclosure. The terminal device in the embodiments of the present disclosure may include, but is not limited to, a mobile terminal such as a mobile phone, a notebook computer, a digital broadcast receiver, a PDA (personal digital assistant), a PAD (tablet computer), a PMP (portable multimedia player), a vehicle terminal (e.g., a car navigation terminal), and the like, and a stationary terminal such as a digital TV, a desktop computer, and the like. The electronic device shown in fig. 5 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present disclosure.
As shown in fig. 5, the electronic device may include a processing means (e.g., central processing unit, graphics processor, etc.) 501 that may perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM)502 or a program loaded from a storage means 508 into a Random Access Memory (RAM) 503. In the RAM 503, various programs and data necessary for the operation of the electronic apparatus are also stored. The processing device 501, the ROM 502, and the RAM 503 are connected to each other through a bus 504. An input/output (I/O) interface 505 is also connected to bus 504.
Generally, the following devices may be connected to the I/O interface 505: input devices 506 including, for example, a touch screen, touch pad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, etc.; output devices 507 including, for example, a Liquid Crystal Display (LCD), speakers, vibrators, and the like; storage devices 508 including, for example, magnetic tape, hard disk, etc.; and a communication device 509. The communication means 509 may allow the electronic device to communicate with other devices wirelessly or by wire to exchange data. While fig. 5 illustrates an electronic device having various means, it is to be understood that not all illustrated means are required to be implemented or provided. More or fewer devices may alternatively be implemented or provided.
In particular, according to an embodiment of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method illustrated in the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network via the communication means 509, or installed from the storage means 508, or installed from the ROM 502. The computer program performs the above-described functions defined in the methods of the embodiments of the present disclosure when executed by the processing device 501.
It should be noted that the computer readable medium in the present disclosure can be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present disclosure, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In contrast, in the present disclosure, a computer readable signal medium may comprise a propagated data signal with computer readable program code embodied therein, either in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: electrical wires, optical cables, RF (radio frequency), etc., or any suitable combination of the foregoing.
The computer readable medium may be embodied in the electronic device; or may exist separately without being assembled into the electronic device.
Computer program code for carrying out operations for aspects of the present disclosure may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, Smalltalk, C + +, and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The units described in the embodiments of the present disclosure may be implemented by software or hardware. Where the name of an element does not in some cases constitute a limitation on the element itself.