Summary of the invention
The present invention mainly provides a kind of communication mode replacing existing instruction type to communicate, and solves state synchronized problem during multi-threading correspondence, and realizes communicating with the communication terminal with multiple extension set.
For solving the problems of the technologies described above, the technical scheme that the present invention adopts is: providing a kind of method of serial communication with having multiple extension set, comprising step:
Call out the number of described communication terminal;
The IP address list of all extension sets in this communication terminal is obtained according to the number of communication terminal;
Send the communications status of self to all IP addresses in IP address list, wherein, communications status is packaged in UDP bag;
The communications status of this extension set that each extension set is replied in received communication terminal, wherein, communications status is packaged in UDP bag;
Analyzing and processing also responds the communications status of this extension set that each extension set replys.
Wherein, described analyzing and processing respond the communications status of this extension set that each extension set replys and be specially:
If the communications status that one or more extension set is replied is conversing with third party device, then end of calling;
If the communications status that extension set is replied be just at jingle bell, then wait extension set is answered, if extension set ring unanswered or wherein extension set rejection, then an end of calling in the scheduled time, if wherein an extension set is answered, then sets up with this extension set and converses one to one.
Wherein, described when there being extension set to answer, set up with this extension set the step conversed one to one and be specially:
The communications status of self is set to converse, and in communications status, adds the IP address connecting extension set;
The form that self communication state is wrapped with UDP is sent to each extension set;
Receive the communications status that each extension set is replied with UDP packet form, judge whether each extension set is hung up, if hang up, no longer send communications status to this extension set; If do not hang up, then continue to send self communication state until other extension sets are all hung up except answering extension set to this extension set, then only converse one to one to answering extension set transmission communications status thus setting up with this extension set.
Wherein, described set up with extension set converse one to one after, send communications status until end of conversation with predetermined space to this extension set.
Wherein, described when obtaining IP address list, also judge whether to obtain successfully, if obtain unsuccessfully, end of calling, if obtain successfully, carries out next step.
Wherein, in described received communication terminal the communications status of this extension set that each extension set is replied step in, if do not receive the reply of any extension set in the given time, end of calling.
The present invention also provides a kind of communication equipment, and it can communicate with the communication terminal with multiple extension set, comprising: calling unit, for calling out the number of described communication terminal; IP address acquisition unit, for obtaining the IP address list of all extension sets in this communication terminal according to the number of communication terminal; Communications status transmitting element, for sending the communications status of self to all IP addresses in IP address list, wherein, communications status is packaged in UDP bag; Communications status receiving element, for the communications status of this extension set that extension set each in received communication terminal is replied, wherein, communications status is packaged in UDP bag; Communications status processing unit, responds for analyzing and processing the communications status of this extension set that each extension set replys.
Wherein, described communications status processing unit also for being set to converse by the communications status of self after having extension set to answer, and adds the IP address of answering extension set in communications status, and is transferred to by this communications status described communications status transmitting element to send.
Wherein, described communication equipment comprises further: judging unit, for judging whether to obtain successfully when obtaining IP address list, if obtain unsuccessfully, pointing out end of calling, if obtain successfully, triggering the work of described communications status transmitting element.
Wherein, described communication equipment comprises further: timing unit, for timing after described communications status transmitting element transmission communications status, if described communications status receiving element does not receive the reply of any extension set in the given time, points out end of calling.
The invention has the beneficial effects as follows: be different from the past based on the communication mode of order, with the communication that the method for the serial communication with multiple extension set is based on state in the present invention, and transmit with the form of UDP bag, in communication process, by the UDP bag that sends containing communications status and receive the bag of the UDP containing communications status that the other side replys and judge whether to set up communication connection and whether communication connection status changes.Communication process is simple, and reporting communications state only needs an information, and in the existing communication based on ordering, control command generally all needs many; Communications status does not need wait acknowledge after sending, and can judge how to process according to the communications status that the other side replys.And send directly to each extension set after the communications status that communication terminal sends is the IP address first obtaining each extension set, can ensure that all extension sets all can receive call request, solve the nonsynchronous problem of each extension set state in communication terminal.The method needs the resource that takies little, is particularly suitable for embedded device.
Embodiment
By describing technology contents of the present invention, structural feature in detail, realized object and effect, accompanying drawing is coordinated to be explained in detail below in conjunction with execution mode.
For ease of understanding, first introduce the system architecture of application method of the present invention, in a communication system, have multiple communication terminal, each communication terminal is all connected into IP network, and IP network can be the Internet, metropolitan area network, local area network (LAN) etc.Wherein, have in certain or some communication terminals and have multiple extension set, each extension set is arranged in consolidated network on switches and with other communication terminals by connecting and can communicates mutually, and each extension set has independently IP address, but shares same call number.Such as, if communication system is a building conversational system, and the communication terminal with multiple extension set is the resident family's machine be installed in man of resident family, using the room number of resident family as call number, then each extension set has different IP addresses, but same call number being shown as to other communication terminals (ladder-port machine and administrative center), namely when being called out resident family's machine by ladder-port machine or administrative center, just room number being called out.
Consult Fig. 1 and Fig. 2, in the present invention, comprise step with the method for the serial communication with multiple extension set:
S10: the number calling out described communication terminal; Wherein, this calling is initiated by calling party's (caller device hereinafter mentioned also refers to calling party), and the number of communication terminal is that system pre-sets, and such as, for the building conversational system that the preceding paragraph is mentioned, number can be room number or administrative center.
S20: the IP address list obtaining all extension sets in this communication terminal according to the number of communication terminal; Preferably, whether successfully also judge to obtain IP address list in this step, if obtain unsuccessfully, end of calling, if obtain successfully, carries out next step; Wherein, the IP address of each extension set is distributed in advance by management software, and manager understands the corresponding relation of stored calls number and IP address, obtaining IP address list in this step can be that caller device obtains result to manager's inquiry in real time, also first all communication number and corresponding IP address are downloaded on local disk before can being caller device, search from local data during calling and obtain result;
S30: the communications status sending self to all IP addresses in IP address list, wherein, communications status is packaged in UDP bag;
S40: the communications status of this extension set that each extension set is replied in received communication terminal, wherein, communications status is packaged in UDP bag; Wherein, in this step, if do not receive the reply of any extension set within a scheduled time, indication equipment goes offline or other network failures, end of calling;
S50: analyzing and processing also responds the communications status of this extension set that each extension set replys.Particularly, consult Fig. 2, if the communications status that one or more extension set is replied is conversing with third party device, then calling party can receive and point out the other side to hurry, end of calling; If the communications status that extension set is replied is just at jingle bell, then wait for that extension set is answered, if extension set ring unanswered in the scheduled time, calling party can receive the prompting of ring unanswered, end of calling; If a wherein extension set rejection, then calling party can receive the prompting of the other side's rejection, end of calling; If wherein an extension set is answered, then set up with this extension set and converse one to one.
The method adopts the communication based on state, and transmit with the form of UDP bag, in communication process, by the UDP bag that sends containing communications status and receive the bag of the UDP containing communications status that the other side replys and judge whether to set up communication connection and whether communication connection status changes.Communication process is simple, and reporting communications state only needs an information, and in the existing communication based on ordering, control command generally all needs many; Communications status does not need wait acknowledge after sending, and can judge how to process according to the communications status that the other side replys.And send directly to each extension set after the communications status that communication terminal sends is the IP address first obtaining each extension set, can ensure that all extension sets all can receive call request, solve the nonsynchronous problem of each extension set state in communication terminal.The method needs the resource that takies little, is particularly suitable for embedded device.
Wherein, in step s 50, by analyzing the communications status received, caller device judges whether the other side answers.Such as, if the communications status that extension set is replied is " in conversing with the equipment of certain IP address ", certain IP address is wherein the third-party IP address with its call, such caller device can know this extension set be in converse with third party in cannot connect with oneself again, end of calling.After having extension set to answer, namely extension set and caller device establish to converse and are connected, and now the communications status of extension set becomes and caller device talking state, and namely caller device carries out respective handling after receiving this communications status, to set up the call one to one with this extension set.Other situation is also corresponding process.
Composition graphs 2 also consults Fig. 3 simultaneously, and particularly, caller device is set up and comprised step with the process of the man-to-man call of extension set:
S51: the communications status of self is set to converse, and in communications status, add the IP address connecting extension set; This IP address is mainly used for the identity representing this connection extension set;
S52: the form that self communication state is wrapped with UDP is sent to each extension set; Sending object now is still multiple extension set, all IP addresses in the IP address list namely obtained in step S20;
S53: receive the communications status that each extension set is replied with UDP packet form, judges whether each extension set is hung up, if hang up, no longer sends communications status to this extension set; If do not hang up, then continue to send self communication state until other extension sets are all hung up except connection extension set to this extension set, then only send communications status to connection extension set thus set up with this extension set and converse one to one.In this step, it is the process that the control module of extension set self is taked according to the communications status of the caller device received that the extension set of access failure is hung up, and can be preset by software program.
In the process that this foundation is conversed one to one, still adopt the communication based on state to make other extension set automatically exit call, and finally set up man-to-man call, be point-to-point communication in communication process, avoid asynchronous problem.Preferably, after setting up converse one to one with extension set, send self communication state until end of conversation with predetermined space to this extension set.In this manner, communication is that duration intervals runs, and can regard heartbeat function as, omit communication heartbeat bag, and without the need to worrying UDP packet loss problem, automatically can recover next time, ensure the state synchronized of both call sides when sending communications status.
Above-mentioned method is the processing mode to the communication terminal calls with multiple extension set, for the communication terminal with multiple extension set, when its as caller device to other communication terminal calls time, each extension set can be used as independently equipment and calls out.When this communication terminal with multiple extension set is as called equipment, between its extension set, whether parallel sessions can set according to the actual requirements.Still for building conversational system, resident family's machine is as a communication terminal, and it has multiple extension set, and actual demand is for when an extension set is in talking state, and other extension sets no longer can be conversed with other communication terminals; For administrative center, have multiple extension set equally, actual demand is for when an extension set is in talking state, and other extension sets still can receive new incoming call.For these two kinds of demands, realize by arranging the difference of extension set.
For resident family's machine, when wherein an extension set is in call, if receive again new call request (the communications status UDP that new caller device sends wraps), the communications status that oneself is replied by the extension set then conversed is in conversing with so-and-so equipment, now caller device receives communications status, judges this extension set access failure then end of calling.
For administrative center, similarly, when wherein an extension set is in call, if receive again new call request (the communications status UDP that new caller device sends wraps), then the extension set conversed does not reply communications status, is equivalent to stealthy state; And communications status replied by other idle extension sets, then caller device makes corresponding judgement and process after receiving communications status.
Consult Fig. 3, the present invention also proposes a kind of with the communication equipment of serial communication with multiple extension set, can comprising:
Calling unit 1, for calling out the number of described communication terminal;
IP address acquisition unit 2, for obtaining the IP address list of all extension sets in this communication terminal according to the number of communication terminal;
Communications status transmitting element 3, for sending the communications status of self to all IP addresses in IP address list, wherein, communications status is packaged in UDP bag;
Communications status receiving element 4, for the communications status of this extension set that extension set each in received communication terminal is replied, wherein, communications status is packaged in UDP bag;
Communications status processing unit 5, responds for analyzing and processing the communications status of this extension set that each extension set replys.
Wherein, the concrete course of work of described communications status processing unit 5 is: if the communications status that one or more extension set is replied is for converse with third party device, then end of calling; If the communications status that extension set is replied be just at jingle bell, then wait extension set is answered, if extension set ring unanswered or wherein extension set rejection, then an end of calling in the scheduled time, if wherein an extension set is answered, then sets up with this extension set and converses one to one.
Wherein, the communications status of self is set to converse by described communications status processing unit 5 after having extension set to answer, and in communications status, add the IP address connecting extension set, and is transferred to by this communications status described communications status transmitting element 3 to send.
This equipment also comprises further:
Judging unit 6, for judging whether to obtain successfully when obtaining IP address list, if obtain unsuccessfully, pointing out end of calling, if obtain successfully, triggering described communications status transmitting element 3 and work.
This equipment also comprises further:
Timing unit 7, for timing after sending communications status at described communications status transmitting element 3, if described communications status receiving element 4 does not receive the reply of any extension set in the given time, points out end of calling.
The foregoing is only embodiments of the invention; not thereby the scope of the claims of the present invention is limited; every utilize specification of the present invention and accompanying drawing content to do equivalent structure or equivalent flow process conversion; or be directly or indirectly used in other relevant technical fields, be all in like manner included in scope of patent protection of the present invention.