CN115623044A - Information interaction method, device, equipment and storage medium based on MQTT protocol - Google Patents

Information interaction method, device, equipment and storage medium based on MQTT protocol Download PDF

Info

Publication number
CN115623044A
CN115623044A CN202211270571.8A CN202211270571A CN115623044A CN 115623044 A CN115623044 A CN 115623044A CN 202211270571 A CN202211270571 A CN 202211270571A CN 115623044 A CN115623044 A CN 115623044A
Authority
CN
China
Prior art keywords
information
task
interaction
instruction
channel
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.)
Pending
Application number
CN202211270571.8A
Other languages
Chinese (zh)
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.)
Agricultural Bank of China
Original Assignee
Agricultural Bank of China
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 Agricultural Bank of China filed Critical Agricultural Bank of China
Priority to CN202211270571.8A priority Critical patent/CN115623044A/en
Publication of CN115623044A publication Critical patent/CN115623044A/en
Pending legal-status Critical Current

Links

Images

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/01Protocols
    • H04L67/12Protocols specially adapted for proprietary or special-purpose networking environments, e.g. medical networks, sensor networks, networks in vehicles or remote metering networks
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04QSELECTING
    • H04Q9/00Arrangements in telecontrol or telemetry systems for selectively calling a substation from a main station, in which substation desired apparatus is selected for applying a control signal thereto or for obtaining measured values therefrom

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Health & Medical Sciences (AREA)
  • Computing Systems (AREA)
  • General Health & Medical Sciences (AREA)
  • Medical Informatics (AREA)
  • Signal Processing (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

The embodiment of the invention discloses an information interaction method, an information interaction device, information interaction equipment and a storage medium based on an MQTT protocol, wherein the method comprises the following steps: acquiring an operation instruction of a user, and analyzing an operation task corresponding to the operation instruction; generating task interaction information with a target server according to the operation task; and sending the task interaction information to the target server through a corresponding information interaction channel, wherein the information interaction channel comprises an instruction transmission channel and a data transmission channel. The technical scheme of the embodiment of the invention solves the problems that only a single information interaction channel can be used for transmitting the interaction information when information interaction is carried out in the prior art, and the real-time performance and the efficiency of the information interaction are insufficient, can provide double information interaction channels for transmitting the interaction information, and improves the real-time performance and the efficiency of the information interaction.

Description

Information interaction method, device, equipment and storage medium based on MQTT protocol
Technical Field
The embodiment of the invention relates to the technical field of communication, in particular to an information interaction method, device, equipment and storage medium based on an MQTT protocol.
Background
The MQTT (Message Queuing Telemetry Transport) protocol is a "lightweight" communication protocol based on a publish/subscribe mode. In the prior art, when information interaction is performed by using an MQTT protocol, only a single information interaction channel can be used for transmitting interaction information, and a data transmission channel can only be used for receiving or sending the interaction information at the same time, so that the real-time performance of interaction information interaction cannot be met, and the information interaction efficiency needs to be improved.
Disclosure of Invention
The embodiment of the invention provides an information interaction method, an information interaction device, information interaction equipment and a storage medium based on an MQTT protocol, which can provide double information interaction channels for transmitting interaction information, improve the real-time performance of information interaction and improve the information interaction efficiency.
In a first aspect, an embodiment of the present invention provides an information interaction method based on an MQTT protocol, which is applied to a client, and the method includes:
acquiring an operation instruction of a user, and analyzing an operation task corresponding to the operation instruction;
generating task interaction information with a target server according to the operation task;
and sending the task interaction information to the target server through a corresponding information interaction channel, wherein the information interaction channel comprises an instruction transmission channel and a data transmission channel.
In a first aspect, an embodiment of the present invention provides an information interaction method based on an MQTT protocol, which is applied to a server, and the method includes:
acquiring task interaction information of a client, and analyzing an operation instruction type corresponding to the operation instruction information when a message main topic of the task interaction information is the operation instruction information;
executing the operation corresponding to the operation instruction information to generate operation feedback information;
and sending the operation feedback information to the client through an information interaction channel corresponding to the operation instruction category, wherein the information interaction channel comprises an instruction transmission channel and a data transmission channel.
In a third aspect, an embodiment of the present invention provides an information interaction device based on MQTT protocol, configured at a client, where the information interaction device includes:
the operation instruction acquisition module is used for acquiring an operation instruction of a user and analyzing an operation task corresponding to the operation instruction;
the task interaction information generating module is used for generating task interaction information with the target server according to the operation task;
and the task interaction information sending module is used for sending the task interaction information to the target server through a corresponding information interaction channel, wherein the information interaction channel comprises an instruction transmission channel and a data transmission channel.
In a fourth aspect, an embodiment of the present invention provides an information interaction device based on MQTT protocol, configured at a server, where the information interaction device includes:
the task interaction information acquisition module is used for acquiring task interaction information of a client, and when a message main topic of the task interaction information is operation instruction information, analyzing an operation instruction type corresponding to the operation instruction information;
the operation feedback information generation module is used for executing the operation corresponding to the operation instruction information and generating operation feedback information;
and the operation feedback information sending module is used for sending the operation feedback information to the client through an information interaction channel corresponding to the operation instruction category, wherein the information interaction channel comprises an instruction transmission channel and a data transmission channel.
In a fifth aspect, an embodiment of the present invention provides a computer device, where the computer device includes:
one or more processors;
a memory for storing one or more programs;
when the one or more programs are executed by the one or more processors, the one or more processors implement the MQTT protocol-based information interaction method according to any embodiment.
In a sixth aspect, the present invention provides a computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements the MQTT protocol-based information interaction method according to any embodiment.
According to the technical scheme provided by the embodiment of the invention, the operation instruction of a user is obtained, and the operation task corresponding to the operation instruction is analyzed; generating task interaction information with a target server according to the operation task; and sending the task interaction information to the target server through a corresponding information interaction channel, wherein the information interaction channel comprises an instruction transmission channel and a data transmission channel. The technical scheme of the embodiment of the invention solves the problems that only a single information interaction channel can be used for transmitting the interaction information when information interaction is carried out in the prior art, and the real-time performance and the efficiency of the information interaction are insufficient, can provide double information interaction channels for transmitting the interaction information, and improves the real-time performance and the efficiency of the information interaction.
Drawings
Fig. 1 is a flowchart of an information interaction method based on MQTT protocol applied to a client according to an embodiment of the present invention;
FIG. 2 is a flowchart of another information interaction method based on MQTT protocol applied to a client according to an embodiment of the present invention;
fig. 3 is a flowchart of an information interaction method based on MQTT protocol applied to a server according to an embodiment of the present invention;
FIG. 4 is a flowchart of another information interaction method based on MQTT protocol applied to a server according to an embodiment of the present invention;
FIG. 5 is a schematic structural diagram of an information interaction device configured on a client according to the MQTT protocol according to an embodiment of the present invention;
FIG. 6 is a schematic structural diagram of an MQTT-based information interaction device configured at a server according to an embodiment of the present invention;
fig. 7 is a schematic structural diagram of a computer device according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, but not all, embodiments of the present invention. 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.
Fig. 1 is a flowchart of an information interaction method based on MQTT protocol applied to a client according to an embodiment of the present invention, where the embodiment of the present invention is applicable to a scenario in which a server interacts with a client, and the method may be executed by an information interaction device based on MQTT protocol, where the information interaction device may be implemented by software and/or hardware.
As shown in fig. 1, the information interaction method based on MQTT protocol includes the following steps:
and S110, acquiring an operation instruction of a user, and analyzing an operation task corresponding to the operation instruction.
The user may be a user operating the client, and the operation instruction may be an instruction generated by the user operating the client. The input mode of the operation instruction includes but is not limited to a touch screen input mode, a voice input mode and the like. The operation task may be a task corresponding to the operation instruction, such as a task of downloading software, uploading a file, and the like. The analysis represents a process of acquiring specific operation task contents from the operation instruction, and after the user inputs the operation instruction, the operation task corresponding to the operation instruction can be analyzed according to the acquired operation instruction information or codes.
And S120, generating task interaction information with the target server according to the operation task.
The target server may be a server that needs to receive task interaction information and execute an operation task. The task interaction information can be interaction information describing an operation task, and the client interacts with the target server through the task interaction information. Furthermore, according to a preset task interaction information generation rule, the theme, the unique identifier and the specific content of the operation task are combined according to a certain sequencing mode to generate the task interaction information with the target server.
S130, the task interaction information is sent to the target server through the corresponding information interaction channel.
The information interaction channel comprises an instruction transmission channel and a data transmission channel, the instruction transmission channel is used for transmitting the instruction type task interaction information, and the instruction transmission channel can transmit the instruction type task interaction information in a serial transmission mode. The data transmission channel is used for transmitting the task interaction information of the data type, and the data transmission channel can simultaneously transmit a plurality of task interaction information in parallel in a serial transmission mode. Further, the type of the task interaction information may be determined according to a preset determination mechanism, for example, the type of the task interaction information may be determined according to a theme type difference in the task interaction information. When the task interaction information is in the instruction type, the task interaction information is sent to a target server through an instruction transmission channel; and when the task interaction information is of a data type, sending the task interaction information to the target server through the data transmission channel. By setting the instruction transmission channel and the data transmission channel, the task interaction information can be sent to the target server side through the corresponding information interaction channel, and the transmission efficiency of information interaction is improved.
According to the technical scheme provided by the embodiment of the invention, the operation instruction of the user is obtained, and the operation task corresponding to the operation instruction is analyzed; generating task interaction information with a target server according to the operation task; and sending the task interaction information to a target server through a corresponding information interaction channel. The technical scheme of the embodiment of the invention solves the problems that only a single information interaction channel can be used for transmitting the interaction information when information interaction is carried out in the prior art, and the real-time performance and the efficiency of the information interaction are insufficient, can provide double information interaction channels for transmitting the interaction information, and improves the real-time performance and the efficiency of the information interaction.
Fig. 2 is a flowchart of another information interaction method based on MQTT protocol applied to a client according to an embodiment of the present invention, where the embodiment of the present invention is applicable to a scenario where a server interacts with the client, and this embodiment further illustrates how to generate task interaction information with a target server according to an operation task based on the foregoing embodiment.
As shown in fig. 2, the information interaction method based on MQTT protocol includes the following steps:
s210, obtaining an operation instruction of a user, and analyzing an operation task corresponding to the operation instruction.
The user may be a user operating the client, and the operation instruction may be an instruction generated by the user operating the client. The input mode of the operation instruction includes but is not limited to a touch screen input mode, a voice input mode and the like. The operation task may be a task corresponding to the operation instruction, such as a task of downloading software, uploading a file, and the like. The analysis represents a process of acquiring specific operation task contents from the operation instruction, and after the user inputs the operation instruction, the operation task corresponding to the operation instruction can be analyzed according to the acquired operation instruction information or codes.
S220, judging the type of the operation task according to a preset judgment rule, and executing the steps S230 and S260 when the operation task is a preset instruction task; when the operation task is a file data transmission task, steps S240, S250 and S260 are performed.
The theme type of the operation task can be used as a preset judgment rule, and when the theme type of the operation task is a command type, the operation task can be determined to be a preset instruction task; when the subject type of the operation task is the data type, it may be determined that the operation task is a file data transfer task.
And S230, when the operation task is a preset instruction task, forming the task interaction information according to a task type theme of the operation task, a task interaction information identifier and a sequence corresponding to the operation task.
The preset instruction task may be an operation task of a preset instruction type. The task type theme can be a theme of an operation task, namely, a summary of a preset instruction task. The task interaction information identifier can be a unique information identifier of the operation task and serves as a unique mark of the operation task. The sequence corresponding to the operation task may be a path of a file corresponding to the operation task. The task interaction information may be information for encapsulating the operation task, and specifically, the task type theme of the operation task, the task interaction information identifier, and the specific content of the operation task may be combined into the task interaction information according to a preset sequence.
Illustratively, when a client needs to view a file list and wants to perform an operation like ls/dir path to view the file list under the server path, a message topic sent by the client is firstly a message identifier msgn no, and a command sequence is attached to form task interaction information, that is, the task interaction information is composed of the message identifier msgn no and the command sequence
MsgNo ls/dir path
S240, when the operation task is a file data transmission task, according to the volume of a file to be transmitted in the file data transmission task, blocking byte data corresponding to the file to be transmitted to obtain a plurality of data blocks.
The file data transmission task may be an operation task of which the type is a data type. The file to be transmitted can be a file which needs to be sent to a server side in a file data transmission task, the volume of the file to be transmitted can be the number of subfiles contained in the file to be transmitted, and further, each subfile can be used as a data block to block byte data corresponding to the file to be transmitted to obtain a plurality of data blocks.
And S250, aiming at each data block, forming a piece of task interaction information by the file identifier to be transmitted, the total number of the data blocks, the data block identifier and the content of the data block.
The file identifier to be transmitted may be a unique information identifier of the file to be transmitted, and is used as a unique mark of the file to be transmitted. The total number of data blocks may be the total number of data blocks contained in the file to be transmitted. The data block identification may be a unique information identification of the data block as a unique mark of the data block. The data block content may be the specific data content of the data block. Furthermore, the file identifier to be transmitted, the total number of the data blocks, the data block identifier and the content of the data blocks can be combined according to a preset sorting mode to form task interaction information of the data blocks, and then the task interaction information of all the data blocks is obtained.
Illustratively, when a client uploads a file, when the client wants to perform an operation similar to put path1[ path2. ] so as to upload n files specified by local path1, path2, etc. to a server, the client starts n threads, and each thread transmits one file respectively. For example, the ith thread transfers the ith file, first reads the file at the local path { i } as byte data, divides the file into m blocks according to the size and the size threshold of the task interaction information, the returned task interaction information is firstly the path { i }, then the delim is a delim, then the total number m of the file blocks of 2 bytes is added, and the sequence number m _ i of 2 bytes represents the m _ i data block currently in the file, and finally the m _ i _ data block is added to form the final task interaction information, namely the final task interaction information
path{i} delim m m_i m_i_data
And S260, sending the task interaction information to the target server through a corresponding information interaction channel.
The information interaction channel comprises an instruction transmission channel and a data transmission channel, the instruction transmission channel is used for transmitting the task interaction information of the instruction type, and the instruction transmission channel can transmit the task interaction information of the instruction type in a serial transmission mode; the data transmission channel is used for transmitting the task interaction information of the data type, and the data transmission channel can simultaneously transmit a plurality of task interaction information in parallel in a serial transmission mode. Further, the corresponding information interaction channel of the task interaction information may be determined according to a preset determination mechanism, for example, the information interaction channel of the task interaction information whose operation task is a preset instruction task may be determined as an instruction transmission channel, and the information interaction channel of the task interaction information whose operation task is a file data transmission task may be determined as a data transmission channel. By setting the instruction transmission channel and the data transmission channel, the task interaction information can be sent to the target server side through the corresponding information interaction channels, and the transmission efficiency of information interaction is improved.
According to the technical scheme provided by the embodiment of the invention, the operation instruction of the user is obtained, and the operation task corresponding to the operation instruction is analyzed; when the operation task is a preset instruction task, task interaction information is formed according to a task type theme of the operation task, a task interaction information identifier and a sequence corresponding to the operation task; when the operation task is a file data transmission task, according to the volume of a file to be transmitted in the file data transmission task, blocking byte data corresponding to the file to be transmitted to obtain a plurality of data blocks; aiming at each data block, forming a piece of task interaction information by a file identifier to be transmitted, the total number of the data blocks, the data block identifier and the content of the data block; and finally, sending the task interaction information to a target server through a corresponding information interaction channel. The technical scheme of the embodiment of the invention solves the problem that the information receiving end in the prior art can not know the transmission condition of all the information interaction files at the first time, so that the information receiving end can know the transmission condition of all the information interaction files at the first time, and the information interaction efficiency is improved.
Fig. 3 is a flowchart of an information interaction method based on MQTT protocol applied to a server, where the embodiment of the present invention is applicable to a scenario where the server interacts with a client, and the method may be executed by an information interaction device based on MQTT protocol, where the device may be implemented by software and/or hardware.
As shown in fig. 3, the information interaction method based on MQTT protocol includes the following steps:
s310, acquiring task interaction information of a client, and analyzing an operation instruction type corresponding to the operation instruction information when a message main topic of the task interaction information is the operation instruction information.
The task interaction information can be interaction information describing an operation task, and the client interacts with the target server through the task interaction information. The message theme can be the theme of the task interaction information, namely the abstract of the task interaction information, the message theme can be divided into operation instruction information and non-operation instruction information, and when the message theme of the task interaction information is the non-operation instruction information, the task interaction information is only received; when the message subject of the task interaction information is the operation instruction information, the operation instruction category corresponding to the operation instruction information needs to be analyzed, and the execution condition of the operation instruction corresponding to the task interaction information is fed back. The operation instruction category may be a type of the operation instruction, and for example, the operation instruction may be divided into a file data transmission instruction and a non-file data transmission instruction according to a preset determination rule.
And S320, executing the operation corresponding to the operation instruction information, and generating operation feedback information.
The operation feedback information may be feedback information generated after the server executes an operation corresponding to the operation instruction information, for example, when the operation instruction is a file data transmission instruction, the operation feedback information is the file data.
S330, sending the operation feedback information to the client through an information interaction channel corresponding to the operation instruction category.
The information interaction channel comprises an instruction transmission channel and a data transmission channel, the instruction transmission channel is used for transmitting operation feedback information of an instruction type, and the instruction transmission channel can transmit the operation feedback information of the instruction type in a serial transmission mode; the data transmission channel is used for transmitting operation feedback information of data types, and the data transmission channel can simultaneously transmit a plurality of operation feedback information in parallel in a serial transmission mode. Furthermore, the type of the operation feedback information can be judged according to a preset judgment mechanism, and when the operation feedback information is of an instruction type, the operation feedback information is sent to the client through an instruction transmission channel; and when the operation feedback information is of a data type, sending the operation feedback information to the client through a data transmission channel. By setting the instruction transmission channel and the data transmission channel, the operation feedback information can be sent to the client through the corresponding information interaction channel, and the transmission efficiency of information interaction is increased.
According to the technical scheme provided by the embodiment of the invention, by acquiring the task interaction information of the client, when the message subject of the task interaction information is the operation instruction information, the operation instruction type corresponding to the operation instruction information is analyzed; executing the operation corresponding to the operation instruction information to generate operation feedback information; and sending the operation feedback information to the client through an information interaction channel corresponding to the operation instruction category. The technical scheme of the embodiment of the invention solves the problems that only a single information interaction channel can be used for transmitting the interaction information when information interaction is carried out in the prior art, and the real-time performance and the efficiency of the information interaction are insufficient, can provide double information interaction channels for transmitting the interaction information, and improves the real-time performance and the efficiency of the information interaction.
Fig. 4 is a flowchart of another information interaction method based on MQTT protocol applied to a server according to an embodiment of the present invention, where the embodiment of the present invention is applicable to a scenario where the server interacts with a client, and the present embodiment further illustrates how to execute an operation corresponding to operation instruction information and generate operation feedback information on the basis of the foregoing embodiment.
As shown in fig. 4, the information interaction method based on MQTT protocol includes the following steps:
s410, acquiring task interaction information of a client, and analyzing the operation instruction type corresponding to the operation instruction information when the message main topic of the task interaction information is the operation instruction information.
The task interaction information can be interaction information describing an operation task, and the client interacts with the target server through the task interaction information. The message theme can be the theme of the task interaction information, namely the abstract of the task interaction information, the message theme can be divided into operation instruction information and non-operation instruction information, and when the message theme of the task interaction information is the non-operation instruction information, the operation instruction in the task interaction information does not need to be executed; when the message topic of the task interaction information is the operation instruction information, the operation instruction category corresponding to the operation instruction information needs to be analyzed. The operation instruction category may be a type of the operation instruction, and for example, the operation instruction may be divided into a file data transmission instruction and a non-file data transmission instruction according to a preset determination rule.
S420, judging the type of the operation instruction according to a preset judgment rule, and executing the steps S430 and S460 when the operation instruction type is a non-file data transmission instruction; when the operation instruction category is a file data transmission instruction, steps S440 and S450 and S460 are performed.
S430, when the operation instruction type is a non-file data transmission instruction, forming operation feedback information based on the identification of the task interaction information and the command sequence corresponding to the operation instruction information.
The non-file data transmission instruction may be an operation instruction that does not require file data transmission. The identification of the task interaction information can be a unique information identification of the task interaction information, and serves as a unique mark of the task interaction information. The sequence corresponding to the operation task may be a path of a file corresponding to the operation instruction information. The operation feedback information may be feedback information generated after the server executes an operation corresponding to the operation instruction information, and specifically, the identifier of the task interaction information and the specific execution condition of the task interaction information are sorted and combined according to a preset sorting manner, so that the operation feedback information may be formed.
For example, when the server determines that the content of the operation instruction is a request for entering the specified path, the server switches the working directory corresponding to the current client to a path. The returned operation feedback information is firstly the original mark MsgNo and then a mark success which indicates whether the mark successfully enters the appointed directory, namely
MsgNo success
S440, when the operation instruction type is a file data transmission instruction, file data blocking is carried out on a target transmission file in the file data transmission instruction to obtain a plurality of data blocks.
The file data transmission instruction may be an operation instruction that needs to perform file data transmission. The target transmission file may be a file to be transmitted, and the target transmission file includes a plurality of subfiles, and each subfile may be a data block, and the byte data corresponding to the file to be transmitted is blocked to obtain a plurality of data blocks.
S450, aiming at each data block, the target transmission file identification, the total quantity of the databases, the data block identification and the content of the data block form an operation feedback message.
The target transmission file identifier may be a unique information identifier of the target transmission file, and serves as a unique mark of the target transmission file. The total number of data blocks may be the total number of data blocks contained in the target transmission file. The data block identification may be a unique information identification of the data block as a unique mark of the data block. The data block content may be the specific data content of the data block. Furthermore, the target transmission file identifier, the total number of the data blocks, the data block identifier and the data block content may be combined according to a preset sorting manner to form operation feedback information of the data block, so as to obtain the operation feedback information of all the data blocks.
Illustratively, when the server determines that the operation instruction is a request for downloading a file, the server starts n threads to transmit the file to the client side in parallel. For example, the ith thread transfers the ith file, first reads the file at path { i } as byte data, divides the file into m blocks according to the size and message body size threshold, returns operation feedback information path { i }, then defines the delim, then adds the total number m of file blocks, and the sequence number m _ i represents the m _ i data block currently in the file, finally adds the file block data m _ i _ data to form the final operation feedback information, i.e. the final operation feedback information is composed
path{i} delim m m_i m_i_data
And S460, sending the operation feedback information to the client through an information interaction channel corresponding to the operation instruction category.
The information interaction channel comprises an instruction transmission channel and a data transmission channel, the instruction transmission channel is used for transmitting operation feedback information of an instruction type, and the instruction transmission channel can transmit the operation feedback information of the instruction type in a serial transmission mode; the data transmission channel is used for transmitting operation feedback information of data types, and the data transmission channel can simultaneously transmit a plurality of operation feedback information in parallel in a serial transmission mode. Further, the type of the operation feedback information may be determined according to a preset determination mechanism, where an information interaction channel corresponding to the operation feedback information of the file data transmission instruction is a data transmission channel, and an information interaction channel corresponding to the operation feedback information of the non-file data transmission instruction is an instruction transmission channel. By setting the instruction transmission channel and the data transmission channel, the operation feedback information can be sent to the client through the corresponding information interaction channel, and the transmission efficiency of information interaction is increased.
When the operation instruction type is a file data transmission instruction, after the client receives the operation feedback information of all the data blocks, the client can know the transmission condition of the operation feedback information of all the data blocks at the first time by checking the total number of the data blocks and the number of the operation feedback information of each data block in the operation feedback information. The technical scheme provided by the embodiment of the invention solves the problems that when the prior art carries out information interaction, a sending end needs to additionally send a notification file once to inform a receiving end whether all files are sent completely, and the receiving also needs to further verify the received files, so that the interactive information receiving end can know the transmission condition of all interactive information at the first time, and the information interaction efficiency is improved.
According to the technical scheme provided by the embodiment of the invention, by acquiring the task interaction information of the client, when the message subject of the task interaction information is the operation instruction information, the operation instruction type corresponding to the operation instruction information is analyzed; when the operation instruction category is a non-file data transmission instruction, forming operation feedback information based on the identification of the task interaction information and a command sequence corresponding to the operation instruction information; carrying out file data blocking on a target transmission file in a file data transmission instruction to obtain a plurality of data blocks; when the operation instruction type is a file data transmission instruction, performing file data blocking on a target transmission file in the file data transmission instruction to obtain a plurality of data blocks; aiming at each data block, forming a piece of operation feedback information by a target transmission file identifier, the total amount of the database, the data block identifier and the content of the data block; and sending the operation feedback information to the client through an information interaction channel corresponding to the operation instruction category. The technical scheme of the embodiment of the invention solves the problems that only a single information interaction channel can be used for transmitting the interaction information when information interaction is carried out in the prior art, and the real-time performance and the efficiency of the information interaction are insufficient, can provide double information interaction channels for transmitting the interaction information, improves the real-time performance and the efficiency of the information interaction, and also can enable an information receiving end to know the transmission condition of all files at the first time, thereby further improving the information interaction efficiency.
Fig. 5 is a schematic structural diagram of an information interaction device configured on a client according to the MQTT protocol according to an embodiment of the present invention, where the information interaction device is applicable to a scenario where a server interacts with the client, and the information interaction device may be implemented by software and/or hardware and integrated in a computer device with an application development function.
As shown in fig. 5, the MQTT protocol-based information interaction device includes: an operation instruction obtaining module 510, a task interaction information generating module 520 and a task interaction information sending module 530.
The operation instruction obtaining module 510 is configured to obtain an operation instruction of a user, and analyze an operation task corresponding to the operation instruction;
a task interaction information generating module 520, configured to generate task interaction information with a target server according to an operation task;
and a task interaction information sending module 530, configured to send the task interaction information to the target server through a corresponding information interaction channel, where the information interaction channel includes an instruction transmission channel and a data transmission channel.
According to the technical scheme provided by the embodiment of the invention, the operation instruction of the user is obtained, and the operation task corresponding to the operation instruction is analyzed; generating task interaction information with a target server according to the operation task; and sending the task interaction information to a target server through a corresponding information interaction channel, wherein the information interaction channel comprises an instruction transmission channel and a data transmission channel. The technical scheme of the embodiment of the invention solves the problem that the information receiving end in the prior art can not know the transmission condition of all the information interaction files at the first time, so that the information receiving end can know the transmission condition of all the information interaction files at the first time, and the information interaction efficiency is improved.
In an optional implementation manner, the task interaction information generating module 520 is specifically configured to:
and when the operation task is a preset instruction task, task interaction information is formed according to the task type theme of the operation task, the task interaction information identifier and the sequence corresponding to the operation task.
In an optional implementation, the task interaction information generating module 520 is further configured to:
when the operation task is a file data transmission task, according to the volume of a file to be transmitted in the file data transmission task, blocking byte data corresponding to the file to be transmitted to obtain a plurality of data blocks;
and aiming at each data block, forming a piece of task interaction information by the file identification to be transmitted, the total number of the data blocks, the data block identification and the content of the data block.
The information interaction device based on the MQTT protocol provided by the embodiment of the invention can execute the information interaction method based on the MQTT protocol applied to the client side provided by any embodiment of the invention, and has corresponding functional modules and beneficial effects of the execution method.
Fig. 6 is a schematic structural diagram of an information interaction apparatus configured at a server and based on MQTT protocol according to an embodiment of the present invention, where the embodiment of the present invention is applicable to a scenario where the server interacts with a client, and the apparatus may be implemented by software and/or hardware and integrated in a computer device with an application development function.
As shown in fig. 6, the MQTT protocol-based information interaction device includes: a task interaction information acquisition module 610, an operation feedback information generation module 620 and an operation feedback information sending module 630.
The task interaction information obtaining module 610 is configured to obtain task interaction information of a client, and when a message topic of the task interaction information is operation instruction information, analyze an operation instruction category corresponding to the operation instruction information;
an operation feedback information generating module 620, configured to execute an operation corresponding to the operation instruction information, and generate operation feedback information;
and an operation feedback information sending module 630, configured to send the operation feedback information to the client through an information interaction channel corresponding to the type of the operation instruction, where the information interaction channel includes an instruction transmission channel and a data transmission channel.
According to the technical scheme provided by the embodiment of the invention, by acquiring the task interaction information of the client, when the message subject of the task interaction information is the operation instruction information, the operation instruction type corresponding to the operation instruction information is analyzed; executing the operation corresponding to the operation instruction information to generate operation feedback information; and sending the operation feedback information to the client through an information interaction channel corresponding to the operation instruction category. The technical scheme of the embodiment of the invention solves the problems that only a single information interaction channel can be used for transmitting the interaction information when information interaction is carried out in the prior art, and the real-time performance and the efficiency of the information interaction are insufficient, can provide double information interaction channels for transmitting the interaction information, and improves the real-time performance and the efficiency of the information interaction.
In an optional implementation manner, the operation feedback information generating module 620 is specifically configured to:
when the operation instruction type is a file data transmission instruction, performing file data blocking on a target transmission file in the file data transmission instruction to obtain a plurality of data blocks;
aiming at each data block, forming a piece of operation feedback information by a target transmission file identifier, the total number of databases, a data block identifier and the content of the data block;
and the information interaction channel corresponding to the operation feedback information of the file data transmission instruction is a data transmission channel.
In an optional implementation, the operation feedback information generating module 620 is further configured to:
when the operation instruction type is a non-file data transmission instruction, forming operation feedback information based on the identification of the task interaction information and a command sequence corresponding to the operation instruction information;
and the information interaction channel corresponding to the operation feedback information of the non-file data transmission instruction is an instruction transmission channel.
The information interaction device based on the MQTT protocol provided by the embodiment of the invention can execute the information interaction method based on the MQTT protocol applied to the server side provided by any embodiment of the invention, and has corresponding functional modules and beneficial effects of the execution method.
Fig. 7 is a schematic structural diagram of a computer device according to an embodiment of the present invention. FIG. 7 illustrates a block diagram of an exemplary computer device 12 suitable for use in implementing embodiments of the present invention. The computer device 12 shown in fig. 7 is only an example and should not bring any limitations to the functionality or scope of use of the embodiments of the present invention. The computer device 12 may be any terminal device with computing capability, and may be configured in an information interaction device based on MQTT protocol.
As shown in FIG. 7, computer device 12 is in the form of a general purpose computing device. The components of computer device 12 may include, but are not limited to: one or more processors or processing units 16, a system memory 28, and a bus 18 that couples various system components including the system memory 28 and the processing unit 16.
Bus 18 may be one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, a processor, or a local bus using any of a variety of bus architectures. By way of example, such architectures include, but are not limited to, industry Standard Architecture (ISA) bus, micro-channel architecture (MAC) bus, enhanced ISA bus, video Electronics Standards Association (VESA) local bus, and Peripheral Component Interconnect (PCI) bus.
Computer device 12 typically includes a variety of computer system readable media. Such media may be any available media that is accessible by computer device 12 and includes both volatile and nonvolatile media, removable and non-removable media.
The system memory 28 may include computer system readable media in the form of volatile memory, such as Random Access Memory (RAM) 30 and/or cache 32. Computer device 12 may further include other removable/non-removable, volatile/nonvolatile computer system storage media. By way of example only, storage system 34 may be used to read from and write to non-removable, nonvolatile magnetic media (not shown in FIG. 7, and commonly referred to as a "hard drive"). Although not shown in FIG. 7, a magnetic disk drive for reading from and writing to a removable, nonvolatile magnetic disk (e.g., a "floppy disk") and an optical disk drive for reading from or writing to a removable, nonvolatile optical disk (e.g., a CD-ROM, DVD-ROM, or other optical media) may be provided. In these cases, each drive may be connected to bus 18 by one or more data media interfaces. System memory 28 may include at least one program product having a set (e.g., at least one) of program modules that are configured to carry out the functions of embodiments of the invention.
A program/utility 40 having a set (at least one) of program modules 42 may be stored, for example, in system memory 28, such program modules 42 including, but not limited to, an operating system, one or more application programs, other program modules, and program data, each of which examples or some combination thereof may comprise an implementation of a network environment. Program modules 42 generally carry out the functions and/or methodologies of the described embodiments of the invention.
Computer device 12 may also communicate with one or more external devices 14 (e.g., keyboard, pointing device, display 24, etc.), with one or more devices that enable a user to interact with computer device 12, and/or with any devices (e.g., network card, modem, etc.) that enable computer device 12 to communicate with one or more other computing devices. Such communication may be through an input/output (I/O) interface 22. Also, computer device 12 may communicate with one or more networks (e.g., a Local Area Network (LAN), a Wide Area Network (WAN), and/or a public network such as the Internet) via network adapter 20. As shown, network adapter 20 communicates with the other modules of computer device 12 via bus 18. It should be appreciated that although not shown in FIG. 7, other hardware and/or software modules may be used in conjunction with computer device 12, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems, among others.
The processing unit 16 executes various functional applications and data processing by running programs stored in the system memory 28, for example, implementing an MQTT protocol-based information interaction method provided by the embodiment of the present invention, the method includes:
acquiring an operation instruction of a user, and analyzing an operation task corresponding to the operation instruction;
generating task interaction information with a target server according to the operation task;
and sending the task interaction information to the target server through a corresponding information interaction channel, wherein the information interaction channel comprises an instruction transmission channel and a data transmission channel.
The present embodiment provides a computer-readable storage medium, on which a computer program is stored, where the program, when executed by a processor, implements an MQTT protocol-based information interaction method according to any embodiment of the present invention, including:
acquiring an operation instruction of a user, and analyzing an operation task corresponding to the operation instruction;
generating task interaction information with a target server according to the operation task;
and sending the task interaction information to the target server through a corresponding information interaction channel, wherein the information interaction channel comprises an instruction transmission channel and a data transmission channel.
Computer storage media for embodiments of the invention may employ any combination of one or more computer-readable media. The computer readable medium may be a computer readable signal medium or a computer readable storage medium. The computer-readable storage medium may be, for example but not limited to: an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples (a non-exhaustive list) of the computer readable storage medium would include the following: 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 context of this document, 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.
A computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, 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: wireless, wire, fiber optic cable, RF, etc., or any suitable combination of the foregoing.
Computer program code for carrying out operations for aspects of the present invention may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, smalltalk, C + +, or the like, as well as 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).
It will be understood by those skilled in the art that the modules or steps of the invention described above may be implemented by a general purpose computing device, they may be centralized on a single computing device or distributed across a network of computing devices, and optionally they may be implemented by program code executable by a computing device, such that it may be stored in a memory device and executed by a computing device, or it may be separately fabricated into various integrated circuit modules, or it may be fabricated by fabricating a plurality of modules or steps thereof into a single integrated circuit module. Thus, the present invention is not limited to any specific combination of hardware and software.
It is to be noted that the foregoing is only illustrative of the preferred embodiments of the present invention and the technical principles employed. It will be understood by those skilled in the art that the present invention is not limited to the particular embodiments illustrated herein, but is capable of various obvious changes, rearrangements and substitutions as will now become apparent to those skilled in the art without departing from the scope of the invention. Therefore, although the present invention has been described in greater detail by the above embodiments, the present invention is not limited to the above embodiments, and may include other equivalent embodiments without departing from the spirit of the present invention, and the scope of the present invention is determined by the scope of the appended claims.

Claims (10)

1. An information interaction method based on an MQTT protocol is applied to a client and is characterized by comprising the following steps:
acquiring an operation instruction of a user, and analyzing an operation task corresponding to the operation instruction;
generating task interaction information with a target server according to the operation task;
and sending the task interaction information to the target server through a corresponding information interaction channel, wherein the information interaction channel comprises an instruction transmission channel and a data transmission channel.
2. The method according to claim 1, wherein when the operation task is a preset instruction task, the generating task interaction information with a target server according to the operation task comprises:
and forming the task interaction information according to the task type theme of the operation task, the task interaction information identification and the sequence corresponding to the operation task.
3. The method according to claim 1, wherein when the operation task is a file data transmission task, the generating task interaction information with a target server according to the operation task comprises:
according to the volume of a file to be transmitted in the file data transmission task, dividing byte data corresponding to the file to be transmitted into blocks to obtain a plurality of data blocks;
and aiming at each data block, forming a piece of task interaction information by the file identification to be transmitted, the total number of the data blocks, the data block identification and the content of the data block.
4. An information interaction method based on MQTT protocol is applied to a server side and is characterized by comprising the following steps:
acquiring task interaction information of a client, and analyzing an operation instruction type corresponding to the operation instruction information when a message main topic of the task interaction information is the operation instruction information;
executing the operation corresponding to the operation instruction information to generate operation feedback information;
and sending the operation feedback information to the client through an information interaction channel corresponding to the operation instruction type, wherein the information interaction channel comprises an instruction transmission channel and a data transmission channel.
5. The method according to claim 4, wherein when the operation instruction type is a file data transmission instruction, the executing an operation corresponding to the operation instruction information to generate operation feedback information includes:
carrying out file data blocking on a target transmission file in the file data transmission instruction to obtain a plurality of data blocks;
aiming at each data block, the target transmission file identification, the total amount of the database, the data block identification and the content of the data block form an operation feedback message;
and the information interaction channel corresponding to the operation feedback information of the file data transmission instruction is the data transmission channel.
6. The method according to claim 4, wherein when the operation instruction type is a non-file data transmission instruction, the executing an operation corresponding to the operation instruction information to generate operation feedback information includes:
forming the operation feedback information based on the identification of the task interaction information and the command sequence corresponding to the operation instruction information;
and the information interaction channel corresponding to the operation feedback information of the non-file data transmission instruction is the instruction transmission channel.
7. An information interaction device based on MQTT protocol, configured at a client, includes:
the operation instruction acquisition module is used for acquiring an operation instruction of a user and analyzing an operation task corresponding to the operation instruction;
the task interaction information generating module is used for generating task interaction information with the target server according to the operation task;
and the task interaction information sending module is used for sending the task interaction information to the target server through a corresponding information interaction channel, wherein the information interaction channel comprises an instruction transmission channel and a data transmission channel.
8. An information interaction device based on MQTT protocol is configured at a server side, and is characterized by comprising:
the task interaction information acquisition module is used for acquiring task interaction information of a client, and when a message main topic of the task interaction information is operation instruction information, analyzing an operation instruction type corresponding to the operation instruction information;
the operation feedback information generation module is used for executing the operation corresponding to the operation instruction information and generating operation feedback information;
and the operation feedback information sending module is used for sending the operation feedback information to the client through an information interaction channel corresponding to the operation instruction category, wherein the information interaction channel comprises an instruction transmission channel and a data transmission channel.
9. A server device, characterized in that the server device comprises:
one or more processors;
a memory for storing one or more programs;
when executed by the one or more processors, cause the one or more processors to implement the MQTT protocol-based information interaction method of any of claims 1-6.
10. A computer-readable storage medium, on which a computer program is stored, which program, when being executed by a processor, carries out the MQTT protocol-based information interaction method according to any one of claims 1 to 6.
CN202211270571.8A 2022-10-17 2022-10-17 Information interaction method, device, equipment and storage medium based on MQTT protocol Pending CN115623044A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211270571.8A CN115623044A (en) 2022-10-17 2022-10-17 Information interaction method, device, equipment and storage medium based on MQTT protocol

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211270571.8A CN115623044A (en) 2022-10-17 2022-10-17 Information interaction method, device, equipment and storage medium based on MQTT protocol

Publications (1)

Publication Number Publication Date
CN115623044A true CN115623044A (en) 2023-01-17

Family

ID=84862315

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211270571.8A Pending CN115623044A (en) 2022-10-17 2022-10-17 Information interaction method, device, equipment and storage medium based on MQTT protocol

Country Status (1)

Country Link
CN (1) CN115623044A (en)

Similar Documents

Publication Publication Date Title
CN111083225B (en) Data processing method and device in Internet of things platform and Internet of things platform
US9497096B2 (en) Dynamic control over tracing of messages received by a message broker
CN111045911B (en) Performance test method, performance test device, storage medium and electronic equipment
CN111221793A (en) Data mining method, platform, computer equipment and storage medium
CN111831618A (en) Data writing method, data reading method, device, equipment and storage medium
CN111111214A (en) Game archive processing method, device and system
CN111694561A (en) Interface management method, device, equipment and storage medium
CN111984849A (en) Information query method, device, equipment and medium
CN113660231A (en) Message parsing method, device, equipment and storage medium
CN111966653A (en) Data processing method, device, server and storage medium for micro-service call link
CN111552521A (en) Application data reporting method, device, server and storage medium
CN113760242A (en) Data processing method, device, server and medium
CN110515749B (en) Method, device, server and storage medium for queue scheduling of information transmission
CN111930385A (en) Data acquisition method, device, equipment and storage medium
CN112948138A (en) Method and device for processing message
CN115623044A (en) Information interaction method, device, equipment and storage medium based on MQTT protocol
CN111835801A (en) File downloading method, device, server, edge device, terminal and medium
CN114461595A (en) Method, device, medium and electronic equipment for sending message
CN113726885A (en) Method and device for adjusting flow quota
CN113761419A (en) Display method and device of topological information, electronic equipment and storage medium
CN111258775A (en) Message processing method, device, equipment and storage medium
CN112468541B (en) Data processing method, device and system based on Internet of things
CN113329076B (en) Data transmission method, device and system, computer equipment and storage medium
CN113806416B (en) Method and device for realizing real-time data service and electronic equipment
CN112087474B (en) Cluster-based port information acquisition 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