Summary of the invention
In view of this, the technical problem to be solved in the present invention is, a kind of information transferring method, Apparatus and system are provided, and can reduce cost and technical difficulty, and can improve the efficiency of transmission of information.
For this reason, the embodiment of the invention adopts following technical scheme:
The embodiment of the invention provides a kind of information transferring method, comprising:
Transmitting terminal message communicator receives the message parameter of required transmission message and address information and the PORT COM information of this message;
According to connecting between described address information and PORT COM information and the receiving terminal message communicator;
Connect when being successfully established, use default message format to generate the first message according to described message parameter, described the first message is sent to receiving terminal message communicator in the described connection of setting up.
Described default message format comprises: task coding and message content; Described task coding is used to indicate the task of the required execution of receiving terminal; Described message content is used to indicate the content of the described task of receiving terminal;
Accordingly, described message parameter comprises: the task coding.
Described transmitting terminal message communicator further comprises before receiving described information:
Transmitting terminal is determined task and the task definition of required execution; Confirm the task coding that task is corresponding according to described task;
Described task coding and task definition are sent to described transmitting terminal message communicator as message parameter.
The described message format that use is preset according to message parameter generates the first message and comprises:
Described task coding and message content are filled into respectively the correspondence position of message format.
Describedly comprise according to connecting between described address information and PORT COM information and the receiving terminal message communicator:
Transmitting terminal message communicator sends connection request according to described address information and PORT COM information to receiving terminal message communicator;
When judgement received the connection response that receiving terminal message communicator returns in Preset Time, connection was successfully established.
The embodiment of the invention also provides a kind of information transferring method, comprising:
Connect between receiving terminal message communicator and the transmitting terminal message communicator;
The first message that receiving end/sending end message communicator is sent in the connection of setting up is resolved from described the first message and is obtained task coding and message content;
Receive the execution result of described task coding indication task, the execution result of described task is obtained by the task that receiving terminal uses described message content to carry out the indication of described task coding;
Receiving terminal message communicator uses default message format to generate the second message according to described execution result, and described the second message is sent to described transmitting terminal message communicator in the connection of setting up.
Receiving terminal message communicator generates the second message according to the default message format of described execution result use and comprises:
Described execution result is filled into the message content part of message format.
The embodiment of the invention also provides a kind of information carrying means, comprising:
Receiving element is used for receiving the message parameter of required transmission message and address information and the PORT COM information of this message;
First sets up the unit, is used for according to connecting between described address information and PORT COM information and the receiving terminal message communicator;
The first transmitting element is used for connecting when being successfully established, and uses default message format to generate the first message according to described message parameter, and described the first message is sent to receiving terminal message communicator in the described connection of setting up.
The first transmitting element comprises:
First generates subelement, is used for connecting when being successfully established, and described task coding and message content are filled into respectively the correspondence position of message format to generate described the first message;
First sends subelement, is used for described the first message is sent to receiving terminal message communicator in the described connection of setting up.
First sets up the unit comprises:
Second sends subelement, is used for sending connection request according to described address information and PORT COM information to receiving terminal message communicator;
First receives subelement, is used for judging when receiving the connection response that receiving terminal message communicator returns in Preset Time, judges to connect to be successfully established.
The embodiment of the invention provides a kind of information carrying means, comprising:
Second sets up the unit, be used for and transmitting terminal message communicator between connect;
Resolution unit is used for the first message that receiving end/sending end message communicator is sent in the connection of setting up, and resolves to obtain task coding and message content from described the first message;
Receiving element, for the execution result that receives described task coding indication task, the execution result of described task is obtained by the task that receiving terminal uses described message content to carry out the indication of described task coding;
The second transmitting element is used for using default message format to generate the second message according to described execution result, and described the second message is sent to described transmitting terminal message communicator in the connection of setting up.
The second transmitting element comprises:
Second generates subelement, is used for described execution result is filled into the message content part of message format, to generate described the second message;
The 3rd sends subelement, is used for described the second message is sent to described transmitting terminal message communicator in the connection of setting up.
The embodiment of the invention also provides a kind of information transmission system, comprising:
Transmitting terminal message communicator is used for receiving the message parameter of required transmission message and address information and the PORT COM information of this message; According to connecting between described address information and PORT COM information and the receiving terminal message communicator; Connect when being successfully established, use default message format to generate the first message according to described message parameter, described the first message is sent to receiving terminal message communicator in the described connection of setting up;
Receiving terminal message communicator, be used for and transmitting terminal message communicator between connect; The first message that receiving end/sending end message communicator is sent in the connection of setting up is resolved from described the first message and is obtained task coding and message content; Receive the execution result of described task coding indication task, the execution result of described task is obtained by the task that receiving terminal uses described message content to carry out the indication of described task coding; Receiving terminal message communicator uses default message format to generate the second message according to described execution result, and described the second message is sent to described transmitting terminal message communicator in the connection of setting up.
Technique effect for technique scheme is analyzed as follows:
At transmitting terminal and receiving terminal the message communicator is set respectively, and in the message communicator presetting message form, by the message communicator carry out with opposite end message communicator between be connected foundation, and generate the message communicator that the first message sends to receiving terminal according to message parameter according to default message format, thereby so that can automatically connect between transmitting terminal and the receiving terminal, improved efficiency of transmission; And, presetting message form in the message communicator directly carries out the transmission of message according to corresponding flow process, thereby so that the form of message and process of transmitting standardization, the program development that only need to carry out a message communicator gets final product, thereby has reduced development cost and technical difficulty.
Embodiment
Below, be described with reference to the accompanying drawings the realization of embodiment of the invention information transferring method and device.
Fig. 1 is a kind of information transferring method schematic flow sheet of the embodiment of the invention, can be applied in the transmitting terminal message communicator, and as shown in Figure 1, the method comprises:
Step 101: transmitting terminal message communicator receives the message parameter of required transmission message and address information and the PORT COM information of this message;
Step 102: according to connecting between described address information and PORT COM information and the receiving terminal message communicator;
Step 103: connect when being successfully established, use default message format to generate the first message according to described message parameter, described the first message is sent to receiving terminal message communicator in the described connection of setting up.
As shown in Figure 2, the embodiment of the invention also provides another kind of information transferring method, is applicable to receiving terminal message communicator, and the method comprises:
Step 201: connect between receiving terminal message communicator and the transmitting terminal message communicator;
Step 202: the first message that receiving end/sending end message communicator is sent in the connection of setting up, from described the first message, resolve and obtain task coding and message content;
Step 203: receive the execution result of described task coding indication task, the execution result of described task is obtained by the task that receiving terminal uses described message content to carry out the indication of described task coding;
Step 204: receiving terminal message communicator uses default message format to generate the second message according to described execution result, and described the second message is sent to described transmitting terminal message communicator in the connection of setting up.
In the method illustrated in figures 1 and 2, at transmitting terminal and receiving terminal the message communicator is set respectively, and in the message communicator presetting message form, by the message communicator carry out with opposite end message communicator between be connected foundation, and generate the message communicator that the first message sends to receiving terminal according to message parameter according to default message format, thereby so that can automatically connect between transmitting terminal and the receiving terminal, improved efficiency of transmission; And, presetting message form in the message communicator directly carries out the transmission of message according to corresponding flow process, thereby so that the form of message and process of transmitting standardization, the program development that only need to carry out a message communicator gets final product, thereby has reduced development cost and technical difficulty.
On the basis of Fig. 1 and Fig. 2, by Fig. 3 embodiment of the invention information transferring method is described in more detail.As shown in Figure 3, the method comprises:
Step 301: transmitting terminal is determined task and the task definition of required execution; Set the tasks the task coding corresponding according to described task; And the address information of definite receiving terminal and PORT COM information, the above-mentioned information of determining is sent to the message communicator of transmitting terminal.
Described task coding is used to indicate the task of the required execution of receiving terminal; Described message content is used to indicate the content of the described task of receiving terminal.
Wherein, pre-stored in transmitting terminal and receiving terminal have the corresponding task of each task coding, thereby transmitting terminal is directly searched described corresponding relation and can be obtained task coding corresponding to described task in this step.
Wherein, described task coding and task definition can be used as message parameter.
Step 302: transmitting terminal message communicator sends connection request according to described receiving terminal address information and PORT COM to the message communicator of described receiving terminal, and the beginning timing; After receiving terminal message communicator receives described connection request, judge whether local described PORT COM is idle, if idle, returns connection response to transmitting terminal message communicator, otherwise, described connection response do not sent.
Step 303: transmitting terminal message communicator is judged when receiving the connection response of described receiving terminal message communicator in Preset Time, determine that the connection between transmitting terminal message communicator and the receiving terminal message communicator is successfully established, then use default message format to generate the first message according to described message parameter, use the described connection of setting up to send to receiving terminal message communicator described the first message.
Wherein, can set in advance corresponding message format in transmitting terminal message communicator and receiving terminal message communicator, concrete form can according to the actual application environment adaptations, not limit here.
For example, described message format can use structure as shown in table 1 below, can comprise message header and message body two parts; Message header can comprise seven parts, is respectively version coding, compressed encoding, scrambled, type of message coding, module coding, function coding and error code.Wherein said version coding, compressed encoding, scrambled, type of message coding and error code generally are the fields that all comprises in each message.Wherein, module coding and function coding are corresponding described task coding.Here, can be large class with task division, by the module coding sign, the concrete function in each large class then identifies by function coding.
Certainly, in actual applications, described module coding and function coding also can be merged into a field, do not limit here.
Described message body is corresponding described message content.
The concrete length of the various piece of above message can independently be set, and does not also limit.For example, in the structure shown in Fig. 3 a, described version is encoded to 4 binary digits, and compressed encoding is 4 binary digits, and described scrambled is 4 binary digits, described type of message is encoded to 4 binary digits, described module coding is 8 binary digits, and described function coding is 8 binary digits, and described error code is 8 binary digits, and the length of message body is not stipulated, can determine by concrete message content length.
At this moment, using default message format to generate the first message according to message parameter described in this step can comprise:
The field location corresponding to corresponding field contents add to, concrete, described task coding and message content are filled into respectively the correspondence position of message format, thereby generate described the first message.
Step 304: receiving terminal message communicator receives described the first message, parses described task coding from described the first message.
Wherein, owing to be provided with same message format in the receiving terminal message communicator, then can be according to the corresponding described task coding that parses in the first message of described message format in this step.
Step 305: receiving terminal determines whether to exist in self this task corresponding task of encoding according to described task coding, if there is execution in step 306; Otherwise, execution in step 307.
Wherein, corresponding relation in the receiving terminal between pre-stored task coding and the task of self carrying out, thereby directly search described corresponding relation in this step, if find corresponding task coding and task corresponding to task coding, show that then this task exists, receiving terminal can be carried out task corresponding to this task coding, execution in step 306; Otherwise, show receiving terminal and can't carry out the task that this task coding is indicated, execution in step 307.
Step 306: receiving terminal is carried out the task of described task coding indication, and task action result corresponding to task coding returned to receiving terminal message communicator; Execution in step 308.
Step 307: receiving terminal returns the task query failure message to receiving terminal message communicator; Execution in step 308.
Wherein, the task query failure message can represent that with different signs this can be by independently setting in the practical application.For example, can return null value to receiving terminal message communicator and not find the task action result that corresponding task obtains correspondence with expression.
Step 308: receiving terminal message communicator uses described default message format to generate the second message according to the described task action result or the described task query failure message that receive, and described the second message is returned to transmitting terminal message communicator in the described connection of setting up.
Wherein, described receiving terminal message communicator in this step uses default message format to generate the second message according to described execution result to comprise: described execution result or described task query failure message are filled into the message content part of message format, to generate described the second message.
Step 309: transmitting terminal message communicator receives and resolves described the second message, obtains described task action result or described task query failure message, and the information that obtains is returned transmitting terminal.
Can realize communication between transmitting terminal and the receiving terminal by above step, wherein, be the setting that task is carried out corresponding task coding at transmitting terminal and receiving terminal, in described message format, tasks carrying content and task coding are separated, the task coding is divided in message header, and the tasks carrying Content placement is in message content part, thereby can carry out more easily the parsing of message so that receive the message communicator of described message, and, so that the expansion of task is more convenient and simple.
And, realize the standardization of transmission of messages by the message communicator, after the exploitation by message communicator successively, can independently carry out in actual applications the setting of message format, so that the transmission of information is more flexible and conveniently, reduced development cost and the technical difficulty in the communication.
Corresponding with above method, the embodiment of the invention also provides a kind of information carrying means, and as described in Figure 4, this device can be arranged in the transmitting terminal as described message communicator, and this device comprises:
The first receiving element 410 is used for receiving the message parameter of required transmission message and address information and the PORT COM information of this message;
First sets up unit 420, is used for according to connecting between described address information and PORT COM information and the receiving terminal message communicator;
The first transmitting element 430 is used for connecting when being successfully established, and uses default message format to generate the first message according to described message parameter, and described the first message is sent to receiving terminal message communicator in the described connection of setting up.
Preferably, the first transmitting element 430 can comprise:
First generates subelement, is used for connecting when being successfully established, and described task coding and message content are filled into respectively the correspondence position of message format to generate described the first message;
First sends subelement, is used for described the first message is sent to receiving terminal message communicator in the described connection of setting up.
First sets up unit 420 can comprise:
Second sends subelement, is used for sending connection request according to described address information and PORT COM information to receiving terminal message communicator;
First receives subelement, is used for judging when receiving the connection response that receiving terminal message communicator returns in Preset Time, judges to connect to be successfully established.
As shown in Figure 5, the embodiment of the invention also provides another kind of information carrying means, can be arranged at receiving terminal as described receiving terminal message communicator, and as shown in Figure 5, this device can comprise:
Second sets up unit 510, be used for and transmitting terminal message communicator between connect;
Resolution unit 520 is used for the first message that receiving end/sending end message communicator is sent in the connection of setting up, and resolves to obtain task coding and message content from described the first message;
The second receiving element 530, for the execution result that receives described task coding indication task, the execution result of described task is obtained by the task that receiving terminal uses described message content to carry out the indication of described task coding;
The second transmitting element 540 is used for using default message format to generate the second message according to described execution result, and described the second message is sent to described transmitting terminal message communicator in the connection of setting up.
Preferably, the second transmitting element 540 can comprise:
Second generates subelement, is used for described execution result is filled into the message content part of message format, to generate described the second message;
The 3rd sends subelement, is used for described the second message is sent to described transmitting terminal message communicator in the connection of setting up.
In addition, the embodiment of the invention also provides a kind of information transmission system, and as shown in Figure 6, this system can comprise:
Transmitting terminal message communicator 610 is used for receiving the message parameter of required transmission message and address information and the PORT COM information of this message; According to connecting between described address information and PORT COM information and the receiving terminal message communicator; Connect when being successfully established, use default message format to generate the first message according to described message parameter, described the first message is sent to receiving terminal message communicator in the described connection of setting up;
Receiving terminal message communicator 620, be used for and transmitting terminal message communicator between connect; The first message that receiving end/sending end message communicator is sent in the connection of setting up is resolved from described the first message and is obtained task coding and message content; Receive the execution result of described task coding indication task, the execution result of described task is obtained by the task that receiving terminal uses described message content to carry out the indication of described task coding; Receiving terminal message communicator uses default message format to generate the second message according to described execution result, and described the second message is sent to described transmitting terminal message communicator in the connection of setting up.
In the device and system of Fig. 4~shown in Figure 6, at transmitting terminal and receiving terminal the message communicator is set respectively, and in the message communicator presetting message form, by transmitting terminal message communicator carry out with receiving terminal message communicator between be connected foundation, and generate the message communicator that the first message sends to receiving terminal according to message parameter according to default message format, thereby so that can automatically connect between transmitting terminal and the receiving terminal, improved efficiency of transmission; And, presetting message form in the message communicator directly carries out the transmission of message according to corresponding flow process, thereby so that the form of message and process of transmitting standardization, the program development that only need to carry out a message communicator gets final product, thereby has reduced development cost and technical difficulty.
One of ordinary skill in the art will appreciate that, the process of the method for realization above-described embodiment can be finished by the relevant hardware of program command, described program can be stored in the read/write memory medium, and this program is carried out the corresponding step in the said method when carrying out.Described storage medium can be such as ROM/RAM, magnetic disc, CD etc.
The above only is preferred implementation of the present invention; should be pointed out that for those skilled in the art, under the prerequisite that does not break away from the principle of the invention; can also make some improvements and modifications, these improvements and modifications also should be considered as protection scope of the present invention.