Patent Publication Number: US-10320663-B2

Title: Communication device, communication system, and computer program product for performing interactive communication via relay servers

Description:
CROSS-REFERENCE TO RELATED APPLICATIONS 
     This application is based upon and claims the benefit of priority from Japanese Patent Application No. 2016-014859, filed on Jan. 28, 2016; the entire contents of which are incorporated herein by reference. 
     FIELD 
     Embodiments described herein relate generally to a communication device, a communication system, and a computer program product. 
     BACKGROUND 
     Widely known are interactive communication systems in which a plurality of client devices are connected to one another via a relay server on the Internet (e.g., Japanese Patent Application Laid-open No. 2011-077890 and Japanese Patent Application Laid-open No. 2008-311852). A first client device out of the client devices establishes a connection with the relay server and maintains the connected state. A second client device also establishes a connection with the relay server. When the first client device, for example, outputs a message after the connection is established between the first and the second client devices and the relay server, the relay server transfers the message to the second client device. In a case where the number of client devices increases, a plurality of relay servers may be provided. 
     In such interactive communication systems, a certain number of relay servers out of the relay servers may possibly be shut down (referred to as scale-in). The interactive communication systems execute scale-in at times when fewer users use the systems, such as night-time, to reduce power consumption or carry out maintenance of the relay servers. 
     When the conventional interactive communication systems described above execute scale-in, there is such a problem that client devices connected to the relay servers to be shut down are momentarily incapable of performing communications. 
     Specifically, when a relay server is shut down, client devices connected to the relay server fail to perform communications if they remain in that state. The client devices need to be switched to another available relay server. After the relay servers are switched, a client device serving as a transmitter of a message and a client device serving as a receiver thereof fail to transmit and receive the message until both of them can establish a connection. 
    
    
     
       BRIEF DESCRIPTION OF THE DRAWINGS 
         FIG. 1  is a block diagram schematically illustrating an exemplary configuration of a communication system applicable to a first embodiment; 
         FIG. 2  is a block diagram more specifically illustrating the exemplary configuration of the communication system applicable to the first embodiment; 
         FIG. 3  is a block diagram of an exemplary hardware configuration of a client device serving as an information processor; 
         FIG. 4  is a block diagram of an exemplary hardware configuration of a client device serving as a home device; 
         FIG. 5  is an exemplary functional block diagram for explaining functions of the client device according to the first embodiment; 
         FIG. 6  is an exemplary functional block diagram for explaining functions of a communication unit according to the first embodiment; 
         FIGS. 7A and 7B  are diagrams for explaining connection establishment processing and message transmission processing performed by the client devices according to the first embodiment; 
         FIGS. 8A to 8C  are diagrams of examples of a device list according to the first embodiment; 
         FIG. 9  is a diagram for explaining connection termination processing performed by the client devices according to the first embodiment; 
         FIGS. 10A and 10B  are diagrams schematically illustrating processing for shifting relay servers according to the first embodiment; 
         FIG. 11  is an exemplary sequence diagram of a process performed by the client device in the processing for shifting the relay servers according to the first embodiment; 
         FIG. 12  is a block diagram of an exemplary configuration of a communication system according to a first modification of the first embodiment; 
         FIG. 13  is a block diagram of an exemplary configuration of a communication system according to a second modification of the first embodiment; 
         FIG. 14  is a block diagram of an exemplary configuration of a communication system according to a third modification of the first embodiment; 
         FIGS. 15A and 15B  are diagrams for explaining processing performed to establish a connection and terminate a connection in a case where the communication system according to the first embodiment is applied to a message broker system; 
         FIG. 16  is a diagram schematically illustrating a configuration of a video compositing system according to the conventional technique; 
         FIGS. 17A and 17B  are diagrams for explaining connection establishment processing and connection termination processing performed by a video compositing system according to another application example of the first embodiment; 
         FIG. 18  is a diagram for explaining communication processing according to a second embodiment; and 
         FIG. 19  is an exemplary flowchart of processing performed by an acquiring unit according to the second embodiment. 
     
    
    
     DETAILED DESCRIPTION 
     A communication device according to an embodiment performs communications with one or more devices via a relay server. To switch a connection destination from a first relay server serving as an origin to a second relay server serving as a destination, the communication device establishes a connection with the second relay server, switches a transmission destination of a message from the first relay server to the second relay server, and cuts a connection with the first relay server. 
     Exemplary embodiments of a communication device, a communication system, and a computer program product are described below. 
     First Embodiment 
       FIG. 1  schematically illustrates an exemplary configuration of a communication system applicable to a first embodiment. The communication system illustrated in  FIG. 1  is a remote control system that controls equipment from a remote information terminal via a communication channel. The communication system  1  includes a plurality of client devices  10 , a plurality of relay servers  20 , and an instructing unit  300   a . In an actual configuration of the communication system, as specifically illustrated in  FIG. 2 , for example, the client devices  10 , the relay servers  20 , and a mediation server  30  functioning as the instructing unit  300   a  are connected in a communicable manner with one another via a network  40 , such as the Internet. 
     The client device  10  is a communication device and may be a smartphone (multifunctional mobile phone) or a tablet computer serving as a portable information processor, for example. The client device  10  is not limited thereto and may be a desktop computer. Alternatively, the client device  10  may be a device including a central processing unit (CPU) and a communication interface (I/F) and connectable to the network  40  out of home devices installed in a user&#39;s house, for example. Examples of the device include, but are not limited to, a video recorder, an air conditioner, etc. 
     The embodiments employ a protocol conforming to WebSocket as a protocol used by the client devices  10  and the relay servers  20  to perform interactive communications. WebSocket is developed by the Internet Engineering Task Force (IETF), and the specification of the protocol is disclosed as RFC6455 (refer to RFC 6455 The WebSocket Protocol, (searched on Dec. 8, 2015) (URL: http://tools.ietf.org/html/rfc6455)). The WebSocket Protocol operates on the Transmission Control Protocol (TCP). 
     The client device  10  functions as a WebSocket client. The relay server  20  functions as a WebSocket server. In the example illustrated in  FIG. 1 , a plurality of client devices  10  are connected to one of the relay servers  20  by WebSocket connections (represented by “WS” in  FIG. 1 ). 
       FIGS. 3 and 4  illustrate exemplary hardware configurations of the client device  10 .  FIG. 3  illustrates an exemplary hardware configuration of a client device  10   a  serving as an information processor. 
     As illustrated in  FIG. 3 , the client device  10   a  includes a CPU  1000 , a read only memory (ROM)  1001 , a random access memory (RAM)  1002 , a graphics I/F  1003 , a display device  1004 , a storage  1005 , an input device  1006 , a data I/F  1007 , and a communication I/F  1008 . These units are connected in a communicable manner with one another via a bus  1010 . 
     The storage  1005  is a non-volatile memory, such as a hard disk drive and a flash memory, and stores therein a computer program and various types of data for operating the CPU  1000 . The ROM  1001  stores therein in advance a computer program and data used to start the client device  10 , for example. Based on the computer programs stored in the storage  1005  and the ROM  1001 , the CPU  1000  controls the entire operation of the client device  10   a  using the RAM  1002  as a work memory. 
     The graphics I/F  1003  converts display information generated based on the computer program by the CPU  1000  into display signals and supplies them to the display device  1004 . The display device  1004  includes a liquid-crystal display (LCD) and a drive circuit that drives the LCD, for example, and displays a screen based on the display signals supplied from the graphics I/F  1003 . The input device  1006  outputs signals corresponding to a user operation. The input device  1006  may be a touch panel integrated with the display device  1004 . 
     The data I/F  1007  inputs and outputs data from and to an external device and may be a universal serial bus (USB), for example. The communication I/F  1008  uses the Transmission Control Protocol/Internet Protocol (TCP/IP) as its communication protocol and controls communications via the network  40 . 
       FIG. 4  illustrates an exemplary hardware configuration of a client device  10   b  serving as a home device. In  FIG. 4 , components common to those in  FIG. 3  are denoted by same reference numerals, and detailed explanation thereof will be omitted. As illustrated in  FIG. 4 , the client device  10   b  includes the CPU  1000 , the ROM  1001 , the RAM  1002 , the storage  1005 , the input device  1006 , the data I/F  1007 , and the communication I/F  1008 , a functional unit I/F  1020 , a functional unit  1021 . The client device  10   b  has a substantially same configuration as that of the client device  10   a  serving as an information processor illustrated in  FIG. 3 . 
     The client device  10   b  is different from the client device  10   a  in that it includes the functional unit I/F  1020  and the functional unit  1021  instead of the graphics I/F  1003  and the display device  1004 . The functional unit  1021  provides functions as a home device of the client device  10   b . In a case where the client device  10   b  is a video recorder, for example, the functional unit  1021  has a television signal receiving function or the like. The functional unit I/F  1020  is an interface of the CPU  1000  for the functional unit  1021 . 
       FIG. 5  is an exemplary functional block diagram for explaining functions of the client device  10  according to the first embodiment. The configuration illustrated in  FIG. 5  is applicable to both of the client device  10   a  serving as an information processor and the client device  10   b  serving as a home device. 
     As illustrated in  FIG. 5 , the client device  10  includes a message generating unit  101 , a distributing unit  102 , a message processing unit  103 , an acquiring unit  104 , a connection managing unit  105 , a device managing unit  106 , and a communication unit  107 . 
     The message generating unit  101 , the distributing unit  102 , the message processing unit  103 , the acquiring unit  104 , the connection managing unit  105 , the device managing unit  106 , and the communication unit  107  are provided by a communication program that operates on the CPU  1000 . The present embodiment, however, is not limited thereto, and part or all of the message generating unit  101 , the distributing unit  102 , the message processing unit  103 , the acquiring unit  104 , the connection managing unit  105 , the device managing unit  106 , and the communication unit  107  may be provided by hardware circuits that cooperate with one another. 
     As illustrated in  FIG. 6 , for example, the communication unit  107  includes connection units  107   a  and  107   b  identified by respective pieces of unique identification information (identification IDs). In  FIG. 6 , the connection units  107   a  and  107   b  are also referred to as a connection unit (#1) and a connection unit (#2), respectively. The connection units  107   a  and  107   b  correspond to WebSocket connections defined by RFC6455. The connection units  107   a  and  107   b  are formed in response to a connection request by WebSocket and establish the connection #1 and the connection #2, respectively, by WebSocket. 
     The message generating unit  101  generates a message to be transmitted from the client device  10  serving as a transmitter to the client device  10  serving as a receiver. In the remote control system, for example, the message generating unit  101  generates a message including a control command. 
     The distributing unit  102  transfers a message transmitted from the message generating unit  101  to the communication unit  107 . The distributing unit  102  requests the communication unit  107  to transmit the message to any one of the relay servers  20 . The distributing unit  102 , for example, requests the communication unit  107  to transmit the message to one of a first relay server  20  and a second relay server  20  out of the relay servers  20 . The distributing unit  102  receives the identification information on the connection unit  107   a  or the connection unit  107   b  serving as a destination from the connection managing unit  105  described below, thereby switching destinations in subsequent distribution. 
     The message processing unit  103  performs predetermined processing based on a message transmitted from the acquiring unit  104 , which will be described later. In the remote control system, for example, the message processing unit  103  changes the state of the client device  10  based on the control command included in the message. 
     The acquiring unit  104  transfers a message received from the connection unit  107   a  or the connection unit  107   b  to the message processing unit  103 . The acquiring unit  104  receives the identification information on the connection unit  107   a  or the connection unit  107   b  serving as a receiver from the connection managing unit  105 , thereby switching receivers in subsequent acquisition. 
     The connection managing unit  105  establishes and terminates a connection by the connection units  107   a  and  107   b . When receiving a shift instruction from the instructing unit  300   a , which will be described later, the connection managing unit  105  performs shift processing on the connection units  107   a  and  107   b  used by the distributing unit  102  and the acquiring unit  104 . The shift processing will be described later in detail. 
     The device managing unit  106  stores the identification information on another client device  10  serving as a communication partner that performs interactive communications with the client device  10  in the RAM  1002  and/or the storage  1005 . 
     The communication program according to the first embodiment is stored in a computer connected to the network  40 , such as the Internet, and provided by being downloaded via the network  40 . The communication program according to the first embodiment may be provided or distributed via the network  40 , such as the Internet. 
     Alternatively, the communication program according to the first embodiment may be recorded and provided in a computer-readable recording medium, such as a compact disc (CD) and a digital versatile disc (DVD), as an installable or executable file. Still alternatively, the communication program may be stored and provided in the ROM  1001 . 
     The communication program according to the first embodiment has a module configuration including the units described above (the message generating unit  101 , the distributing unit  102 , the message processing unit  103 , the acquiring unit  104 , the connection managing unit  105 , the device managing unit  106 , and the communication unit  107 ). In actual hardware, the CPU  1000  reads and executes the communication program from the storage  1005  to load the units on a main memory (e.g., the RAM  1002 ). The units thus are generated on the main memory. 
     The relay server  20  according to the first embodiment includes a CPU, a ROM, a RAM, a storage, and a communication I/F. Because the relay server  20  has a configuration equivalent to that of a typical computer, detailed explanation of the hardware configuration thereof will be omitted. The relay server  20  according to the first embodiment functions as a WebSocket server. When receiving a request to establish a WebSocket connection from the client device  10 , the relay server  20  establishes a connection with the client device  10  according to the procedure defined by RFC6455. 
     The relay server  20  stores therein a corresponding relation between the pieces of identification information on the client devices  10  serving as a pair that performs interactive communications. The relay server  20  uses the corresponding relation to transfer a message transmitted from one client device  10  to another client device  10  that makes a pair with the one client device  10 . As described above, the relay server  20  functions as a relay for interactive communications performed between a plurality of client devices  10 . 
     The instructing unit  300   a  according to the first embodiment, for example, periodically transmits a request to acquire the present total number of WebSocket connections to the relay servers  20  respectively. In response to the acquisition request, the relay servers  20  acquire the number of WebSocket connections connected to the respective relay servers  20  and transmit the result to the instructing unit  300   a . Based on the information on the number of connections acquired from the relay servers  20 , the instructing unit  300   a  determines whether to execute scale-out or scale-in of the relay servers  20 . 
     The instructing unit  300   a , for example, calculates the upper-limit number of connectable WebSocket connections from the value in performance of the relay servers  20 . The instructing unit  300   a  then calculates the ratio of the present number of connections to the upper-limit number to compare the calculated ratio with a threshold. If the ratio exceeds the threshold in all the relay servers  20 , the instructing unit  300   a  determines to execute scale-out (addition of an instance of a new relay server  20 ). By contrast, if the ratio falls below the threshold in a specific relay server  20 , the instructing unit  300   a  determines to execute scale-in (discard of an instance of the relay server  20 ). 
     If the instructing unit  300   a  determines to execute scale-in, the instructing unit  300   a  issues, to the relay server  20  the instance of which is to be discarded, a shift instruction to shift connections of the client devices  10  connected thereto to another relay server  20 . The shift instruction includes identification information for identifying the destination relay server  20  to which the connections are to be shifted. The relay server  20  that receives the shift instruction transmits the shift instruction to the client devices  10  connected to the relay server  20 . The shift instruction is received by the client devices  10  and transferred to the respective connection managing units  105 . When receiving the shift instruction, the connection managing units  105  in the respective client devices  10  start the shift processing, which will be described later. 
     Connection and Termination Processing According to the First Embodiment 
     The following describes processing performed to establish a connection and terminate the connection between the client devices  10  in the communication system according to the first embodiment. Specifically, the following describes connection establishment processing and message transmission processing performed by the client devices  10   a  and  10   b  according to the first embodiment with reference to  FIGS. 7A and 7B . 
     In  FIG. 7A , the client device  10   b  serving as a home device, for example, first establishes a WebSocket connection with the relay server  20 , and the client device  10   a  serving as an information processor and a communication partner of the client device  10   b  then establishes the WebSocket connection with the relay server  20 . 
     The connection managing unit  105  of the client device  10   b  starts connection establishment processing for a connection with the relay server  20  in response to a predetermined event, such as a user operation and a power-on operation performed on the client device  10   b . Specifically, the connection managing unit  105  of the client device  10   b  transmits, to the relay server  20 , a connection establishment request including client identification information (referred to as “B”) for identifying the client device  10   b  and forms the connection unit  107   a  in the communication unit  107  (Step S 10 ). 
     The relay server  20  stores the client identification information “B” transmitted from the client device  10   b  in a storage area of the relay server  20  or an external database (Step S 11 ). In response to the connection establishment request, the relay server  20  performs connection establishment processing for a connection of the client device  10   b  with the relay server  20 . 
     Subsequently, the connection managing unit  105  of the client device  10   a  transmits, to the relay server  20 , a connection establishment request including client identification information (referred to as “A”) on the client device  10   a  and the client identification information “B” on the client device  10   b  with which the client device  10   a  desires to perform communications and forms the connection unit  107   a  in the communication unit  107  (Step S 12 ). The client device  10   a  is informed of the client identification information “B” on the client device  10   b  serving as a communication partner in advance. 
     The relay server  20  stores therein a corresponding relation (referred to as a corresponding relation “A-B”) between the client identification information “A” included in the connection establishment request transmitted from the client device  10   a  and the client identification information “B” transmitted from the client device  10   b  (Step S 13 ). In response to the connection establishment request, the relay server  20  performs connection establishment processing for a connection of the client device  10   a  with the relay server  20 . This processing enables the client device  10   a  and the client device  10   b  to perform interactive communications via the relay server  20 . 
     The relay server  20  notifies the client device  10   b  serving as a communication partner of the client device  10   a  that a new connection is established with the client device  10   a  (Step S 14 ). This notification is referred to as a new connection notification. The new connection notification includes the client identification information “A” on the client device  10   a  with which the connection is established. The client device  10   b  receives the new connection notification via the connection unit  107   a  and transfers it to the device managing unit  106 . Based on the client identification information “A” included in the received new connection notification, the device managing unit  106  creates a list of the identification information (device list). 
       FIG. 8A  illustrates an example of the device list created based on the client identification information “A” received at Step S 12  according to the first embodiment. In the example illustrated in  FIG. 8A , the device list stores therein the client identification information “A”. The device managing unit  106  stores the created device list in the RAM  1002  and/or the storage  1005 . When receiving a new connection notification, the device managing unit  106  adds the client identification information included in the received new connection notification to the list. Similarly to this, the client device  10   a  adds the client identification information “B” on the client device  10   b  serving as a communication partner to the device list of its own device managing unit  106  when the connection establishment is completed. 
       FIG. 7B  illustrates an example of processing performed when the client device  10   b  outputs a message. The client device  10   b  transmits a message including the client identification information “B” on the client device  10   b  serving as a source and the client identification information “A” of the client device  10   a  serving as a destination to the relay server  20  (Step S 20 ). 
     The relay server  20  interprets the message to extract the pieces of client identification information “A” and “B” from the message. The relay server  20  refers to the corresponding relation “A-B” stored in the connection establishment processing (Step S 21 ) to determine whether the pieces of client identification information “A” and “B” are a pair that performs interactive communications. If the relay server  20  determines that the pieces of client identification information “A” and “B” are a pair, the relay server  20  transfers the message to the client device  10   a  (Step S 22 ). 
     By contrast, if the relay server  20  determines that the pieces of client identification information “A” and “B” are not a pair, the relay server  20  transmits an error message to the client device  10   b , for example. 
     As described above, the relay server  20  manages the corresponding relation between the pieces of identification information on the client devices  10  that perform interactive communications. Let us assume a case where the corresponding relation “A-B” is stored in the relay server  20 , and another client device  10  having client identification information “C” issues a connection establishment request to the relay server  20 . The connection establishment request indicates that the client identification information on a communication partner is “A”. In this case, the relay server  20  stores therein two corresponding relations “A-B” and “A-C”. 
     The client device  10   b  also receives the new connection notification on the client device  10  having the client identification information “C” and adds the client identification information “C” to the device list.  FIG. 8B  illustrates an example of the device list obtained by adding the client identification information “C” to the device list illustrated in  FIG. 8A . 
     The following describes connection termination processing performed by the client devices  10   a  and  10   b  according to the first embodiment with reference to  FIG. 9 . In this example, the client devices  10   a  and  10   b  and the client device  10  having the client identification information “C” are connected to the relay server  20 . The relay server  20  stores therein two corresponding relations “A-B” and “B-C”. 
     The connection managing unit  105  of the client device  10   a  transmits a connection termination notification including the client identification information “A” to the relay server  20  in response to a predetermined event, such as a user operation (Step S 30 ). In response to the connection termination notification, the relay server  20  refers to the stored corresponding relations between the pieces of client identification information to search for the client identification information (client identification information “B” in this example) having a corresponding relation with the client identification information “A”. As a result of the search, the relay server  20  acquires the corresponding relations “A-B” and “B-C”. 
     Based on the acquired corresponding relation “A-B”, the relay server  20  notifies the client device  10   b  that a connection termination notification is transmitted from the client device  10   a . This notification is referred to as a removal notification (Step S 31 ). The removal notification includes the client identification information “A” on the client device  10   a  serving as the transmitter of the connection termination notification. The client device  10   b  transfers the received removal notification via the connection unit  107   a  to the device managing unit  106 . Based on the removal notification, the device managing unit  106  deletes the client identification information “A” from the device list (Step S 32 ).  FIG. 8C  illustrates an example of the device list obtained by deleting the client identification information “A” from the device list illustrated in  FIG. 8B . 
     Subsequently, the relay server  20  deletes the client identification information “A” and the corresponding relation “B-C” including the client identification information “A” stored in the relay server  20  (Step S 33 ). The relay server  20  notifies the client device  10   a  of completion of the processing (Step S 34 ). In response to the processing completion notification, the client device  10   a  cuts the WebSocket connection with the relay server  20  (Step S 35 ) and deletes the client identification information “B” on the client device  10   b  serving as a communication partner from the device list in its own device managing unit  106 . The series of termination processing is thus ended. 
     While the removal notification is transmitted from the client device  10  in this example, the embodiment is not limited thereto. When the relay server  20  detects forced disconnection in one client device  10  or disconnection because of unexpected reason, for example, the relay server  20  may transmit a removal notification to another client device  10  having a corresponding relation with the first client device  10 . The removal notification may have a structure of a will in the message queueing telemetry transport (MQTT), for example. 
     With the processing performed by the client device  10  to establish and terminate a connection described above, the client device  10  dynamically stores therein the client identification information on another client device  10  currently being a communication partner of the client device  10 . 
     Processing for Shifting the Relay Servers According to the First Embodiment 
     The following describes processing for shifting the relay servers  20  according to the first embodiment.  FIGS. 10A and 10B  schematically illustrate the processing for shifting the relay servers  20  according to the first embodiment. As illustrated in  FIG. 10A , the communication system includes two relay servers  20   a  and  20   b , three client devices  10   d ,  10   e , and  10   f  having pieces of client identification information “D”, “E”, and “F”, respectively, and the instructing unit  300   a . The client devices  10   d ,  10   e , and  10   f  establish WebSocket connections with the relay server  20   a.    
     The client device  10   d  serves as a communication partner of the client devices  10   e  and  10   f . The client device  10   d  stores the pieces of client identification information “E” and “F” in the device list. The client devices  10   e  and  10   f  store the client identification information “D” in the device list. The relay server  20   a  stores therein corresponding relations “D-E” and “D-F”. 
     Let us assume a case where the instructing unit  300   a  issues, to the client devices  10   d  to  10   f , a shift instruction to shift the connections of the client devices  10   d  to  10   f  from the relay server  20   a  to the relay server  20   b .  FIG. 10B  illustrates a state where the connections of the client devices  10   d  to  10   f  are shifted to the relay server  20   b  in response to the shift instruction. The shift instruction includes identification information on the relay server  20   b  serving as a destination. The identification information on the relay server  20   b  serving as a destination may be an Internet Protocol (IP) address of the relay server  20   b  on the network  40 , for example. 
       FIG. 11  is an exemplary sequence diagram of a process performed by the client device in the processing for shifting the relay servers according to the first embodiment. In  FIG. 11 , components common to those in  FIGS. 5, 6, and 10  are denoted by same reference numerals, and detailed explanation thereof will be omitted. The process illustrated in  FIG. 11  is common to the client devices  10   d ,  10   e , and  10   f . In the following description, the client device  10   d  represents the client devices  10   d ,  10   e , and  10   f  if not otherwise specified. 
     Before the start of the process in the sequence diagram illustrated in  FIG. 11 , the client device  10   d  creates the connection unit  107   a  in the communication unit  107 , and the connection unit  107   a  establishes a connection between the client device  10   d  and the relay server  20   a . At this time, establishment of a connection between the client device  10   d  and the relay server  20   b  is not started yet, and the connection unit  107   b  is not created yet. 
     In  FIG. 11 , the instructing unit  300   a  transmits a shift instruction including the identification information on the relay server  20   b  serving as a destination to the client devices  10   d ,  10   e , and  10   f  connected to the relay server  20   a  (Step S 100 ). If the client device  10   d  receives the shift instruction transmitted from the instructing unit  300   a , the client device  10   d  transfers the received shift instruction to the connection managing unit  105 . 
     In response to the received shift instruction, the connection managing unit  105  issues a connection establishment request to the relay server  20   b  specified by the shift instruction and starts processing for establishing a WebSocket connection with the relay server  20   b  according to the procedure defined by RFC6455 (Step S 101 ). As a result, the connection unit  107   b  is newly created in the communication unit  107 . The connection unit  107   b  performs processing for establishing the WebSocket connection with the relay server  20   b . If the connection unit  107   b  succeeds in establishing a connection with the relay server  20   b , the connection unit  107   b  notifies the connection managing unit  105  of the success (Step S 102 ). 
     If the connection managing unit  105  receives the success notification from the connection unit  107   b , the connection managing unit  105  transmits an establishment completion notification indicating completion of establishment of a connection with the relay server  20   b  serving as a destination to the connection unit  107   a  that maintains the connection with the relay server  20   a  serving as an origin (Step S 103 ). The connection unit  107   a  transmits, to the relay server  20   a , the establishment completion notification including the client identification information “D” on the client device  10   d  serving as a source. If the connection unit  107   a  succeeds in transmitting the establishment completion notification, the connection unit  107   a  notifies the connection managing unit  105  of the success (Step S 104 ). 
     If the relay server  20   a  receives the establishment completion notification transmitted from the connection unit  107   a  of the client device  10   d  based on the processing at Step S 104 , the relay server  20   a  refers to the stored corresponding relations to transfer the establishment completion notification to the client devices  10   e  and  10   f  having corresponding relations with the client device  10   d . The processing of transferring the establishment completion notification corresponds to the processing of transferring the new connection notification described at Step S 14  in  FIG. 7A . 
     The connection managing unit  105  transmits a device list acquisition request to the device managing unit  106  (Step S 105 ). In response to the device list acquisition request, the device managing unit  106  acquires a device list (Step S 106 ). Based on the acquired device list, the device managing unit  106  acquires the client identification information on the client device currently being in communication with the client device  10   d . At Step S 107 , the connection managing unit  105  waits until it receives establishment completion notifications corresponding to all the pieces of client identification information included in the acquired device list. 
     Similarly to the client device  10   d , the client devices  10   e  and  10   f  being in communication with the relay server  20   a  also receive the shift instruction from the instructing unit  300   a . The client devices  10   e  and  10   f  also perform the processing from Step S 101  to Step S 104  in response to the shift instruction, thereby transmitting an establishment completion notification to the client device  10   d  from the respective connection units  107   a  via the relay server  20   a . The connection managing unit  105  of the client device  10   d  waits until it receives the establishment completion notifications corresponding to the pieces of client identification information “E” and “F” stored in the device list acquired at Step S 106 . 
     If the connection managing unit  105  determines that it receives the establishment completion notifications corresponding to all the pieces of client identification information included in the acquired device list at Step S 107 , the process is shifted to Step S 108 . At Step S 108 , the connection managing unit  105  issues, to the distributing unit  102 , a switching instruction to switch connection units so as to transmit a message subsequently received from the message generating unit  101  using the connection unit  107   b  newly created at Step S 101 . In response to the switching instruction, the distributing unit  102  performs predetermined processing (e.g., setting of destination information added to the message) to transmit the message to the relay server  20   b , for example. If the processing is completed, the distributing unit  102  notifies the connection managing unit  105  of completion of the switching (Step S 109 ). 
     If the connection managing unit  105  receives the switching completion notification from the distributing unit  102 , the connection managing unit  105  transmits a transmission termination notification (FIN) to the relay server  20   a  using the connection unit  107   a  (Step S 110 ). The transmission termination notification notifies the relay server  20   a  that no more message is to be transmitted from the client device  10   d  via the connection unit  107   a . The connection managing unit  105  transmits the transmission termination notification including the client identification information “D” indicating the client device  10   d  serving as a source. If the connection unit  107   a  succeeds in transmitting the connection termination notification to the relay server  20   a , the connection unit  107   a  notifies the connection managing unit  105  of the success (Step S 111 ). 
     If the relay server  20   a  receives the transmission termination notification from the client device  10   d , the relay server  20   a  transfers the received transmission termination notification to the client devices  10   e  and  10   f  having corresponding relations with the client device  10   d  in the same manner as that of the establishment completion notification. Similarly to the processing of transferring the establishment completion notification, the processing of transferring the transmission termination notification also corresponds to the processing of transferring the new connection notification performed at Step S 14  in  FIG. 7A . 
     If the connection managing unit  105  receives the success notification from the connection unit  107   a , the connection managing unit  105  waits for transmission termination notifications transmitted from the client devices  10   e  and  10   f  (Step S 112 ). 
     By receiving the transmission termination notifications from both of the client devices  10   e  and  10   f , the connection managing unit  105  can determine that no more message is to be transmitted from any partner to itself, that is, to the client device  10   d  via the connection unit  107   a . If the connection managing unit  105  receives the transmission termination notifications from both of the client devices  10   e  and  10   f , the connection managing unit  105  transmits a connection termination request to the connection unit  107   a  according to the procedure defined by RFC6455 (Step S 113 ). In response to this, the connection unit  107   a  cuts the connection with the relay server  20   a.    
     If the connection unit  107   a  succeeds in cutting the connection, the connection unit  107   a  notifies the connection managing unit  105  of the success (Step S 114 ). If the connection managing unit  105  receives the notification indicating the success in cutting the connection from the connection unit  107   a , the connection managing unit  105  notifies the instructing unit  300   a  of completion of the shift performed in response to the shift instruction received at Step S 100  (Step S 115 ). 
     With the process described above, the client devices  10   d ,  10   e , and  10   f  according to the first embodiment can shift the connections from the relay server  20   a  to which they are connected to the relay server  20   b  as follows: the client devices  10   d ,  10   e , and  10   f  switch the transmission destination of a message to the relay server  20   b  at a timing when they determine that connections are established between the relay server  20   b  serving as a destination and the respective connection units  107   b  and that the client devices  10   d ,  10   e , and  10   f  can perform interactive communications with the relay server  20   b . This mechanism can prevent instantaneous interruption in transmission of the message when the connections are shifted from the relay server  20   a  to the relay server  20   b.    
     Furthermore, the client devices  10   d ,  10   e , and  10   f  according to the first embodiment terminates the connections via the connection units  107   a  at a timing when they determine that no more message is to be transmitted to or received from the relay server  20   a  serving as an origin via the respective connection units  107   a . This mechanism enables prompt release of resource consumption. 
     First Modification of the First Embodiment 
     The following describes a first modification of the first embodiment. While the instructing unit  300   a  according to the first embodiment directly transmits the shift instruction to the client devices  10 , the embodiment is not limited thereto.  FIG. 12  illustrates an exemplary configuration of a communication system according to the first modification of the first embodiment. As illustrated in  FIG. 12 , an instructing unit  300   b  according to the first modification of the first embodiment transmits a shift instruction to the client devices  10  via the relay server  20  to which the client devices  10  are connected. 
     In the example illustrated in  FIG. 12 , the instructing unit  300   b  acquires the number of WebSocket connections from the relay servers  20 . Based on the information on the number of WebSocket connections acquired from the relay servers  20 , the instructing unit  300   b  determines whether to shift the connection destination of all the client devices  10  connected to a certain relay server  20  to another relay server  20 , for example. 
     The instructing unit  300   b , for example, shifts the connections of all the client devices  10  connected to the relay server  20  having the number of WebSocket connections exceeding a threshold out of the relay servers  20  to another relay server  20 . The relay server  20  serving as a destination may be determined by selecting the relay server  20  having the smallest number of WebSocket connections out of the numbers of WebSocket connections in order, for example. 
     The instructing unit  300   b  transmits a shift instruction including the identification information (e.g., the IP address) on the relay server  20  serving as a destination to the relay server  20  serving as an origin. When receiving the shift instruction, the relay server  20  serving as an origin duplicates and transmits the shift instruction to all the client devices  10  connected to the relay server  20  serving as an origin. Subsequent processing is the same as the processing from Step S 101  in  FIG. 11 . 
     Second Modification of the First Embodiment 
     The following describes a second modification of the first embodiment.  FIG. 13  illustrates an exemplary configuration of a communication system according to the second modification of the first embodiment. While the instructing unit  300   a  according to the first embodiment is independent hardware, such as the mediation server  30 , instructing units  300   c  according to the second modification of the first embodiment are provided in respective relay servers  20 ′ as illustrated in  FIG. 13 . 
     In this case, the instructing unit  300   c  monitors various states of the relay server  20 ′ to which the instructing unit  300   c  belongs (e.g., the number of WebSocket connections, the CPU usage rate, the memory usage, and the operating state of other devices). The instructing units  300   c  of the respective relay servers  20 ′ may perform communications with one another to monitor the relay servers  20 ′ besides the relay server  20  to which each instructing unit  300   c  belongs. With this configuration, the instructing unit  300   c  can issue a shift instruction when determining that a failure occurs in the relay server  20 ′ to which the instructing unit  300   c  belongs, for example. 
     Third Modification of the First Embodiment 
     The following describes a third modification of the first embodiment.  FIG. 14  illustrates an exemplary configuration of a communication system according to the third modification of the first embodiment. The communication system illustrated in  FIG. 14  is obtained by adding a determining unit  310  to the configuration of the communication system illustrated in  FIG. 1 . An instructing unit  300   d  issues a termination instruction to a specific relay server  20 . Furthermore, client devices  10 ′ have a slightly different configuration to make an inquiry on a shift destination, which will be described later. 
     While the shift instruction according to the first embodiment includes the identification information on the relay server  20  serving as a destination, the embodiment is not limited thereto. The instructing unit  300   d  according to the third modification of the first embodiment issues a termination instruction to a specific relay server  20  but issues no instruction indicating the relay server  20  to which the client devices  10 ′ connected to the specific relay server  20  supplied with the termination instruction are to be shifted. The relay server  20  that receives the termination instruction transmits the shift instruction including no identification information on the relay server  20  serving as a destination to the client devices  10 ′. 
     When receiving the shift instruction from the relay server  20 , the client devices  10 ′ inquires of the determining unit  310  to which relay server  20  the client devices  10 ′ are to be shifted. Similarly to the instructing unit  300   b  according to the first modification of the first embodiment, the determining unit  310  acquires the number of WebSocket connections from the relay servers  20 . Based on the information on the number of WebSocket connections acquired from the relay servers  20 , the determining unit  310  determines the relay server  20  serving as a destination. The determining unit  310  outputs the identification information on the relay server  20  determined to be the destination as a response to the inquiry from the client devices  10 ′. The client devices  10 ′ perform the processing from Step S 101  in  FIG. 11  on the relay server  20  specified in the response, thereby performing the processing for shifting the relay servers  20 . 
     Fourth Modification of the First Embodiment 
     The following describes a fourth modification of the first embodiment. While the client devices  10  according to the first embodiment transmit the new connection notification and the removal notification to one another, thereby updating the device lists in the respective connection managing units  105  to the latest state, the embodiment is not limited thereto. The client devices  10  may transmit no new connection notification or no removal notification. Instead of transmitting the notifications, the client devices  10  may store therein a history of the client identification information on the client device  10  serving as a transmitter of a message previously transmitted to the respective client devices  10  and create the device list based on the history. 
     In this case, in transmission of a message at Step S 22  in  FIG. 7B , for example, the relay server  20  adds the client identification information on the client device  10   b  serving as a transmitter to the message transferred to the client device  10   a . When receiving the message, the acquiring unit  104  of the client device  10   a  transfers the client identification information on the transmitter added to the message to the device managing unit  106 . The device managing unit  106  stores the client identification information transferred from the acquiring unit  104  in the storage  1005 , for example, in an accumulative manner. With this mechanism, the device managing unit  106  of the client device  10   a  can manage the client identification information on the client device  10   b  that has transmitted a message to the client device  10   a.    
     Fifth Modification of the First Embodiment 
     The following describes a fifth modification of the first embodiment. While the transmission termination notification transmitted at Step S 110  in  FIG. 11  according to the first embodiment includes the client identification information on the client device  10  serving as a transmitter, the embodiment is not limited thereto. The transmission termination notification according to the fifth modification of the first embodiment includes no client identification information on the client device  10  serving as a transmitter. In this case, the connection managing unit  105  waits until it receives transmission termination notifications of the number of client devices  10  included in the device list. 
     As illustrated in  FIGS. 10A and 10B , for example, let us assume a case where the connection destination of the client devices  10   d ,  10   e , and  10   f  is shifted from the relay server  20   a  (refer to  FIG. 10A ) to the relay server  20   b  (refer to  FIG. 10B ). In this case, the connection managing unit  105  of the client device  10   d , for example, waits until it receives two transmission termination notifications. 
     As described above, to switch the connection of the client device  10  from the relay server  20  serving as an origin to the relay server  20  serving as a destination, the client device  10  according to the first embodiment and the modifications thereof establishes a connection with the relay server  20  serving as a destination before cutting the connection with the relay server  20  serving as an origin. This mechanism can prevent the client device  10  from being momentarily incapable of performing communications in association with the switching of the connection. 
     The client devices  10  according to the first embodiment and the modifications thereof transmit, to one another, an establishment completion notification indicating completion of the connection with the relay server  20  serving as a destination. The client devices  10  switch the relay servers  20  to which they transmit a message when all the client devices  10  connected to the same relay server  20  complete establishment of the connection. This mechanism can prevent instantaneous interruption in transmission of the message due to difference between the client devices  10  in the timing when they complete establishing the connection. 
     The client devices  10  according to the first embodiment and the modifications thereof transmit the transmission termination notification to one another. The client devices  10  cut the old connection at a timing when the client devices  10  determine that no more message is to be transmitted to them. This mechanism can release the resource consumption at a timing when the connection becomes unnecessary, thereby promptly making the relay server  20  capable of being shut down. In a case where the instance of the relay server  20  is charged by time unit, for example, this mechanism can reduce the charge for use of the instance of the relay server  20 . 
     The client device  10  according to the first embodiment and the modifications thereof always manages the device list of the client devices  10  that perform communications with itself. In the processing for shifting the relay servers  20 , the client device  10  waits until it receives the transmission termination notification from all the client devices  10  included in the device list. Even if a plurality of pairs of client devices  10  perform interactive communications, this mechanism can appropriately control the timing to cut the connection with the relay server  20  serving as an origin. 
     Let us assume a case of a communication system in which the client devices  10  are mobile terminals and home devices, and the mobile terminals perform remote control on the home devices, for example. In the switching of the relay servers  20  according to the conventional technology, there is a time lag after an instruction of control is issued before completion is actually detected, thereby deteriorating usability for a user. In another example, let us assume a case of a communication system that transmits a message requiring immediacy, such as an emergency notification in a disaster. In the switching of the relay servers  20  according to the conventional technology, delay in the notification leads to delay in an initial response, resulting in occurrence of a problem. By applying the communication system according to the first embodiment and the modifications thereof to the cases described above, these problems can be solved. 
     Another Application Example of the First Embodiment 
     The following describes another application example of the first embodiment where the communication system according to the first embodiment is applied to a message broker system. The system configuration of the message broker system may be the same as that of the communication system according to the first embodiment described with reference to  FIG. 1 . In other words, the message broker system may have the system configuration in which the client devices  10  are connected to the relay servers  20  via a communication channel, such as the network  40 , to perform interactive communications among the client devices  10 . 
     In the message broker system, the relay servers  20  function as broker servers that relay messages. The messages transmitted and received by the message broker system each include an address referred to as a topic. After being connected to the broker server (relay server  20 ), the client device  10  (referred to as a publisher) that desires to transmit a message transmits the message using the topic as a destination. A client (referred to as a subscriber) who wants to receive the message connects the broker server in advance and notifies the broker server of the name of the topic to which the client wants to subscribe. If the publisher transmits a message to the topic, the broker server distributes the message to all the subscribers who subscribe to the topic. 
     The following describes connection establishment processing and connection termination processing performed by the client devices  10  and processing for shifting the broker servers (relay servers  20 ) in the message broker system. 
     The following describes processing performed by the client devices  10  to establish a connection and terminate a connection in a case where the communication system according to the first embodiment is applied to the message broker system with reference to  FIGS. 15A and 15B . In  FIGS. 15A and 15B , a broker server  21  corresponds to the relay server  20 , and client devices  10   g  and  10   h  correspond to the client device  10   a  serving as a computer. The pieces of client identification information on the client devices  10   g  and  10   h  are “G” and “H”, respectively. 
     In  FIG. 15A , the client device  10   g  first establishes a WebSocket connection with the broker server  21 , and the client device  10   h  then establishes a WebSocket connection with the broker server  21 , for example. 
     The client device  10   g  performs processing for establishing a connection with the broker server  21  (Step S 40 ). If the connection is established, the client device  10   g  subscribes to a topic “group 1” for managing a group of communication partners (Step S 41 ). The connection managing unit  105  of the client device  10   g , for example, stores the information on the topic “group 1” to which the client device  10   g  subscribes in the RAM  1002  or the storage  1005 . 
     The client device  10   g  transmits a message “join G” including the client identification information “G” to the topic “group 1” to which the client device  10   g  subscribes (Step S 42 ). The message “join G” notifies other client devices (e.g., the client device  10   h ) that subscribe to the same topic “group 1” that the client device  10   g  joins in as a communication partner. 
     Subsequently, the client device  10   h  performs the same connection establishment processing (Step S 43 ). If the connection with the broker server  21  is established, the client device  10   h  subscribes to the topic “group 1” (Step S 44 ). The client device  10   h  transmits a message “join H” including the client identification information “H” to the topic “group 1” (Step S 45 ). The message “join H” is transmitted to the client device  10   g  that subscribes to the topic “group 1” (Step S 46 ). 
     If the client device  10   g  receives the message “join H”, the client device  10   g  adds the client identification information “H” to the device list in its own connection managing unit  105 , thereby updating the device list. The client devices  10   g  and  10   h  may periodically transmit the pieces of client identification information “G” and “H” in the messages “join G” and “join H”, respectively, thereby keeping the respective device lists up-to-date. 
       FIG. 15B  illustrates an example of processing performed by the client device  10   h  to terminate a connection. To terminate the connection, the client device  10   h  transmits a message “remove H” including the client identification information “H” as a message indicating removal to the same topic “group 1” as that in the establishment of the connection (Step S 50 ). The message “remove H” is distributed to the client device  10   g  via the broker server  21  (Step S 51 ). 
     If the client device  10   g  receives the message “remove H”, the client device  10   g  deletes the client identification information “H” from the device list in the connection managing unit  105  of the client device  10   g  based on the client identification information “H” included in the received message “remove H”. With this processing, the client device  10   g  can keep the device list for managing the client device that performs communications with the client device  10   g  up-to-date. 
     The process for issuing the removal notification is not limited thereto. The client device  10   h , for example, may issue the removal notification using a will function defined by a message protocol, such as MQTT. In this case, after establishing a connection, the client device  10   h  registers a message similar to the removal notification in the broker server  21  as a will defined by MQTT. When the connection with the client device  10   h  is cut, the broker server  21  transmits the removal notification to the client device  10   g  that subscribes to the topic “group 1” based on the will. 
     The process for switching the broker servers  21  is different from the process from Step S 101  on in the sequence diagram illustrated in  FIG. 11  in the processing at Step S 103  for transmitting an establishment completion notification and the processing at Step S 110  for transmitting a transmission termination notification. In the present application example of the first embodiment, when the connection unit  107   b  of the client device  10   g  completes establishment of a connection with the broker server  21  serving as a destination, the client device  10   g  transmits, to the topic “group 1”, an establishment completion notification, such as “ESTABLISH G” including the client identification information “G” on the client device  10   g  serving as a transmitter. Similarly to this, when transmission is terminated, the client device  10   g  transmits a transmission termination notification, such as “FIN G”, including the client identification information “G” on the client device  10   g  serving as a transmitter as a notification indicating that no more message is to be transmitted from the client device  10   g  via the connection unit  107   a  to the broker server  21  serving as an origin. After the transmission termination notification is transmitted, the client device  10   h  terminates a WebSocket connection with the broker server  20  (Step S 52 ). 
     As described above, the communication system according to the first embodiment is also applicable to the message broker system, and the message broker system can provide the same advantageous effects as those of the first embodiment. Especially when the first embodiment is applied to the message broker system, the message broker system can provide the same advantageous effects as those of the first embodiment without changing the configuration of the conventional message broker, thereby saving time and effort in development. 
     Still Another Application Example of the First Embodiment 
     The following describes still another application example of the first embodiment where the communication system according to the first embodiment is applied to a video compositing system. The system configuration of the video compositing system may be the same as that of the communication system according to the first embodiment described with reference to  FIG. 1 . In other words, the video compositing system may have the system configuration in which the client devices  10  are connected to the relay servers  20  via a communication channel, such as the network  40 , to perform interactive communications among the client devices  10 . 
       FIG. 16  schematically illustrates a configuration of a video compositing system according to the conventional technology. The video compositing system includes a plurality of video servers  11  and a video compositing server  22 . The video servers  11  transmit video sources  50   a ,  50   b , and  50   c . The video compositing server  22  composites the video sources  50   a ,  50   b , and  50   c  transmitted from the video servers  11  and transmits a composited video source to one or more viewers  12 . The video compositing server  22  transmits composite video obtained by compositing the video sources  50   a ,  50   b , and  50   c  to the viewers  12 . The viewers  12  correspond to the client device  10   a  serving as a computer illustrated in  FIG. 3 , for example. The viewers  12  display the composite video transmitted from the video compositing server  22  based on an installed video display program. 
     The viewer  12  can specify a layout for compositing video in the video compositing server  22  in advance. The video compositing server  22  composites the video sources  50   a ,  50   b , and  50   c  based on the layout specified by the viewer  12  and transmits the composite video to the viewer  12  that specifies the layout. In the example illustrated in  FIG. 16 , the video compositing server  22  composites the video sources  50   a ,  50   b , and  50   c  based on layouts specified by the respective viewers  12  and transmits composite video  51   a  and  51   b  to the respective viewers  12  that specify the layouts. 
     The following describes processing performed by the client devices to establish a connection and terminate a connection in the video compositing system according to the present application example of the first embodiment with reference to  FIGS. 17A and 17B . In  FIGS. 17A and 17B , video compositing servers  22   a  and  22   b  correspond to the relay servers  20  in  FIG. 1 . Video servers  11   a ,  11   b , and  11   c  and viewers  12   a  and  12   b  correspond to the client devices  10  in  FIG. 1 . The video servers  11   a ,  11   b , and  11   c  transmit the video sources  50   a ,  50   b , and  50   c , respectively. An instructing unit  300   e  transmits a shift instruction to the video servers  11   a ,  11   b , and  11   c  and the viewers  12   a  and  12   b.    
     The video servers  11   a ,  11   b , and  11   c  have pieces of client identification information “Va”, “Vb”, and “Vc”, respectively. The viewers  12   a  and  12   b  have pieces of client identification information “Ba” and “Bb”, respectively. The following describes processing performed by the video servers  11   a ,  11   b , and  11   c  and the viewers  12   a  and  12   b  to establish a connection with the video compositing server  22   a , for example, with reference to  FIG. 17A . 
     If the video compositing server  22   a  receives a connection establishment request from a client device of one type out of the two types of client devices of the video servers  11   a ,  11   b , and  11   c  and the viewers  12   a  and  12   b , the video compositing server  22   a  transmits a new connection notification to client devices of other type. 
     Let us assume a case where the video compositing server  22   a  receives a connection establishment request from the viewer  12   a  serving as a client device of the one type, for example. In this case, the video compositing server  22   a  transmits a new connection notification indicating that the viewer  12   a  is to be newly connected to the video compositing server  22   b  to the video servers  11   a ,  11   b , and  11   c  serving as client devices of the other type based on stored corresponding relations. If the video servers  11   a ,  11   b , and  11   c  receive the new connection notification of the viewer  12   a , they update the respective device lists based on the client identification information “Ba” included in the received new connection request. 
     When the video servers  11   a ,  11   b , and  11   c  and the viewers  12   a  and  12   b  establish connections with the video compositing server  22   a , for example, the device managing unit  106  of the video servers  11   a ,  11   b , and  11   c  stores therein the device list including the pieces of client identification information “Ba” and “Bb” on the viewers  12   a  and  12   b , respectively. The device managing unit  106  of the viewers  12   a  and  12   b  stores therein the device list including the pieces of client identification information “Va”, “Vb”, and “Vc” on the video servers  11   a ,  11   b , and  11   c , respectively. The video compositing server  22   a  stores therein corresponding relations between the video servers  11   a ,  11   b , and  11   c  and the viewers  12   a  and  12   b.    
     The video servers  11   a ,  11   b , and  11   c  and the viewers  12   a  and  12   b  perform the processing to terminate connections with the video compositing server  22   a , for example, in the same manner as described above. Specifically, if the video compositing server  22   a  receives a removal notification from a client device of one type out of the two types of client devices of the video servers  11   a ,  11   b , and  11   c  and the viewers  12   a  and  12   b  connected to the video compositing server  22   a , the video compositing server  22   a  transmits the removal notification to client devices of other type. 
     Let us assume a case where the video compositing server  22   a  receives a removal notification from the viewer  12   a  serving as a client device of the one type, for example. In this case, the video compositing server  22   a  transmits a removal notification indicating to the effect that the viewer  12   a  is to be removed to the video servers  11   a ,  11   b , and  11   c  serving as client devices of the other type based on the stored corresponding relations. If the video servers  11   a ,  11   b , and  11   c  receive the removal notification of the viewer  12   a , they update the respective device lists based on the client identification information “Ba” included in the received removal notification. 
     If the video servers  11   a ,  11   b , and  11   c  and the viewers  12   a  and  12   b  receive a shift instruction from the instructing unit  300   e , they perform the processing from Step S 101  on in  FIG. 11 . The video servers  11   a ,  11   b , and  11   c  and the viewers  12   a  and  12   b  thus perform the processing for shifting connections from the video compositing server  22   a  to which they are connected to the video compositing server  22   b  serving as a destination, for example (see  FIG. 17B ). 
     Second Embodiment 
     The following describes a second embodiment. The client device  10  according to the first embodiment and the modifications thereof transmits the transmission termination notification in the switching of the relay servers  20 . By contrast, the client device  10  in the communication system according to the second embodiment adds a value that uniquely varies based on a predetermined rule, such as a serial number in ascending order, to a message to be transmitted without transmitting the transmission termination notification. Based on the serial number, the client device  10  detects completion of switching of the relay servers  20 . 
     The following describes the communication processing according to the second embodiment with reference to  FIG. 18 . The communication system according to the second embodiment has the same configuration as that of the communication system according to the first embodiment described with reference to  FIG. 1 .  FIG. 18  illustrates components of the client device  10  greatly relating to the operation according to the second embodiment (the acquiring unit  104 , the connection managing unit  105 , the connection units  107   a , and the connection unit  107   b  illustrated in  FIGS. 5 and 6 ). The communication processing is described below appropriately with reference to  FIGS. 1, 5, and 6 . 
     In the example illustrated in  FIG. 18 , the processing to Step S 108  in  FIG. 11  is performed, for example. Specifically, assume that the connection unit  107   a  is connected to the relay server  20  serving as an origin, and the connection unit  107   b  is connected to the relay server  20  serving as a destination. 
     The distributing unit  102  illustrated in  FIG. 5  adds a serial number (sequence number) for identifying the order of messages to a message transmitted from the message generating unit  101 . Transmission of data via the network  40  is typically carried out by a packet unit by dividing the data into a predetermined size and adding header information or the like thereto. The distributing unit  102 , for example, generates the sequence numbers for the respective packets and stores them in headers. In the following description, the sequence number is a value incremented by 1. 
     In  FIG. 18 , the acquiring unit  104  extracts the sequence number from the received message and checks that the value of the extracted sequence number sequentially increases in each message. After the connection managing unit  105  issues a switching instruction to the distributing unit  102  at Step S 108  in  FIG. 11 , the connection managing unit  105  issues a wait request to the acquiring unit  104  as illustrated in  FIG. 18 . 
     The acquiring unit  104  monitors the sequence numbers added to the messages transmitted from the connection unit  107   a  and the connection unit  107   b . The acquiring unit  104  waits until it receives, from the connection unit  107   b , a message (message having a sequence number “4”) next to a sequence number (“3” in this example) of the last message received from the connection unit  107   a . Specifically, the acquiring unit  104  waits until it receives, from the connection unit  107   b , a message with a sequence number having a value larger by 1 than the largest sequence number out of the sequence numbers added to the messages received from the connection unit  107   a.    
     If the acquiring unit  104  receives the message, the acquiring unit  104  determines that switching from the connection unit  107   a  to the connection unit  107   b  is completed and returns the processing to the connection managing unit  105 . The connection managing unit  105  issues a connection termination request for the connection unit  107   a  connected to the relay server  20  serving as an origin. With this process, the connection managing unit  105  can determine that no more message is to be transmitted hereafter from any communication partner to the client device  10  via the connection unit  107   a.    
       FIG. 19  is an exemplary flowchart of the processing performed by the acquiring unit  104  according to the second embodiment. At Step S 200 , the acquiring unit  104  receives a message from the connection unit  107   a  or the connection unit  107   b . At Step S 201 , the acquiring unit  104  acquires the sequence number added to the received message. 
     At Step S 202 , the acquiring unit  104  determines whether the sequence number acquired at Step S 201  is a number (number having a value larger by 1) next to the largest sequence number of the acquired sequence numbers. If the acquiring unit  104  determines that the sequence number is not the number next to the largest sequence number (No at Step S 202 ), the processing is returned to Step S 200 , and the acquiring unit  104  performs the processing on the next message. 
     On the other hand, if the acquiring unit  104  determines that the sequence number is the number next to the largest sequence number (Yes at Step S 202 ), the processing is shifted to Step S 203 . At Step S 203 , the acquiring unit  104  acquires source information (connection ID) indicating whether the message with the sequence number is received from the connection unit  107   a  or the connection unit  107   b . The acquiring unit  104  stores the source information associated with the sequence number acquired at Step S 201  in the RAM  1002  or the like. 
     At Step S 204 , the acquiring unit  104  compares the source information acquired at Step S 203  with the source information associated with a sequence number (number having a value smaller by 1) previous to the sequence number acquired at Step S 201  to determine whether the pieces of source information indicate different sources. In a case where the source information (connection ID) acquired at Step S 203  indicates the connection unit  107   b , and the source information associated with the previous sequence number indicates the connection unit  107   a , for example, the acquiring unit  104  determines that the sources are different. If the acquiring unit  104  determines that the sources are the same (No at Step S 204 ), the processing is returned to Step S 200 . 
     By contrast, if the acquiring unit  104  determines that the sources are different (Yes at Step S 204 ), the processing is shifted to Step S 205 . At Step S 205 , the acquiring unit  104  notifies the connection managing unit  105  of completion of switching. The processing at Step S 205  corresponds to the processing from Step S 109  to Step S 111  in  FIG. 11 , for example. 
     While certain embodiments have been described, these embodiments have been presented by way of example only, and are not intended to limit the scope of the inventions. Indeed, the novel embodiments described herein may be embodied in a variety of other forms; furthermore, various omissions, substitutions and changes in the form of the embodiments described herein may be made without departing from the spirit of the inventions. The accompanying claims and their equivalents are intended to cover such forms or modifications as would fall within the scope and spirit of the inventions.