(self, connection_name, hostname, port, **kwargs)
return client_channel
Add new peer to the node.

        :param connection_name:    Connection name.
        :type connection_name:     str

        :param hostname:    hostname of the remote node.
        :type hostname:     str

        :param port:    port of the remote node.
        :type port:     int

        :param auto_remote_event:   An optional keyword argument which if
                                    defined, bind events automatically to remote
                                    execution. **Default:** ``{}`` (no events)
        :type auto_remote_event:    dict

        :param channel: An optional keyword argument which if defined,
                        set channel used for client event. If this keyword is
                        not defined the method will generate the channel name
                        automatically.
        :type channel:  str

        :param reconnect_delay: An optional keyword argument which if defined,
                                set auto reconnect delay.
                                **Default:** ``10`` (seconde)
        :type reconnect_delay:  int

        :param receive_event_firewall:  An optional keyword argument which if
                                        defined, function or method to call for
                                        check if event is allowed for sending.
                                        **Default:** ``None`` (no firewall)
        :type receive_event_firewall:   function
        :type receive_event_firewall:   method

        :param send_event_firewall:  An optional keyword argument which if
                                    defined, setfunction or method to call to
                                    check if event is allowed for executing
                                    **Default:** ``None`` (no firewall)
        :type send_event_firewall:   function
        :type send_event_firewall:   method

        :return: Channel used on client event.
        :rtype: str
Add new peer to the node.
Add new peer to the node .
def add(self, connection_name, hostname, port, **kwargs):
        """Add new peer to the node.

        :param connection_name:    Connection name.
        :type connection_name:     str

        :param hostname:    hostname of the remote node.
        :type hostname:     str

        :param port:    port of the remote node.
        :type port:     int

        :param auto_remote_event:   An optional keyword argument which if
                                    defined, bind events automatically to remote
                                    execution. **Default:** ``{}`` (no events)
        :type auto_remote_event:    dict

        :param channel: An optional keyword argument which if defined,
                        set channel used for client event. If this keyword is
                        not defined the method will generate the channel name
                        automatically.
        :type channel:  str

        :param reconnect_delay: An optional keyword argument which if defined,
                                set auto reconnect delay.
                                **Default:** ``10`` (seconde)
        :type reconnect_delay:  int

        :param receive_event_firewall:  An optional keyword argument which if
                                        defined, function or method to call for
                                        check if event is allowed for sending.
                                        **Default:** ``None`` (no firewall)
        :type receive_event_firewall:   function
        :type receive_event_firewall:   method

        :param send_event_firewall:  An optional keyword argument which if
                                    defined, setfunction or method to call to
                                    check if event is allowed for executing
                                    **Default:** ``None`` (no firewall)
        :type send_event_firewall:   function
        :type send_event_firewall:   method

        :return: Channel used on client event.
        :rtype: str
        """
        # automatic send event to peer
        auto_remote_event = kwargs.pop('auto_remote_event', {})
        for event_name in auto_remote_event:
            for channel in auto_remote_event[event_name]:
                @handler(event_name, channel=channel)
                def event_handle(self, event, *args, **kwargs):
                    yield self.call(remote(event, connection_name))
            self.addHandler(event_handle)

        client_channel = kwargs.pop(
            'channel',
            '%s_client_%s' % (self.channel, connection_name)
        )
        reconnect_delay = kwargs.pop('reconnect_delay', 10)
        client = Client(hostname, port, channel=client_channel, **kwargs)

        # connected event binding
        @handler('connected', channel=client_channel)
        def connected(self, hostname, port):
            self.fire(connected_to(
                connection_name, hostname, port, client_channel, client
            ))
        self.addHandler(connected)

        # disconnected event binding
        @handler('disconnected', 'unreachable', channel=client_channel)
        def disconnected(self, event, *args, **kwargs):
            if event.name == 'disconnected':
                self.fire(disconnected_from(
                    connection_name, hostname, port, client_channel, client
                ))

            # auto reconnect
            if reconnect_delay > 0:
                Timer(
                    reconnect_delay,
                    connect(hostname, port),
                    client_channel
                ).register(self)

        self.addHandler(disconnected)

        client.register(self)
        self.__peers[connection_name] = client
        return client_channel
def add ( self , connection_name , hostname , port , * * kwargs ) : # automatic send event to peer auto_remote_event = kwargs . pop ( 'auto_remote_event' , { } ) for event_name in auto_remote_event : for channel in auto_remote_event [ event_name ] : @ handler ( event_name , channel = channel ) def event_handle ( self , event , * args , * * kwargs ) : yield self . call ( remote ( event , connection_name ) ) self . addHandler ( event_handle ) client_channel = kwargs . pop ( 'channel' , '%s_client_%s' % ( self . channel , connection_name ) ) reconnect_delay = kwargs . pop ( 'reconnect_delay' , 10 ) client = Client ( hostname , port , channel = client_channel , * * kwargs ) # connected event binding @ handler ( 'connected' , channel = client_channel ) def connected ( self , hostname , port ) : self . fire ( connected_to ( connection_name , hostname , port , client_channel , client ) ) self . addHandler ( connected ) # disconnected event binding @ handler ( 'disconnected' , 'unreachable' , channel = client_channel ) def disconnected ( self , event , * args , * * kwargs ) : if event . name == 'disconnected' : self . fire ( disconnected_from ( connection_name , hostname , port , client_channel , client ) ) # auto reconnect if reconnect_delay > 0 : Timer ( reconnect_delay , connect ( hostname , port ) , client_channel ) . register ( self ) self . addHandler ( disconnected ) client . register ( self ) self . __peers [ connection_name ] = client return client_channel