コード例 #1
0
ファイル: connect.py プロジェクト: TonyWildish/DDM
    def __notify(self, frame_type, headers=None, body=None):
        """
        Utility function for notifying listeners of incoming and outgoing messages
        
        \param frame_type the type of message
        
        \param headers the map of headers associated with the message
        
        \param body the content of the message
        """
        for listener in self.__listeners.values():
            if not hasattr(listener, 'on_%s' % frame_type):
                log.debug('listener %s has no method on_%s' % (listener, frame_type))
                continue

            if frame_type == 'connecting':
                listener.on_connecting(self.__current_host_and_port)
                continue

            notify_func = getattr(listener, 'on_%s' % frame_type)
            params = backward.get_func_argcount(notify_func)
            if params >= 3:
                notify_func(headers, body)
            elif params == 2:
                notify_func(headers)
            else:
                notify_func()
コード例 #2
0
ファイル: connect.py プロジェクト: cloudspaces/pyactive
    def __notify(self, frame_type, headers=None, body=None):
        """
        Utility function for notifying listeners of incoming and outgoing messages
        
        \param frame_type the type of message
        
        \param headers the map of headers associated with the message
        
        \param body the content of the message
        """
        if frame_type == 'receipt':
            # logic for wait-on-receipt notification
            self.__send_wait_condition.acquire()
            self.__receipts[headers['receipt-id']] = None
            self.__send_wait_condition.notify()
            self.__send_wait_condition.release()

        for listener in self.__listeners.values():
            if not hasattr(listener, 'on_%s' % frame_type):
                log.debug('listener %s has no method on_%s' % (listener, frame_type))
                continue

            if frame_type == 'connecting':
                listener.on_connecting(self.__current_host_and_port)
                continue

            notify_func = getattr(listener, 'on_%s' % frame_type)
            params = backward.get_func_argcount(notify_func)
            if params >= 3:
                notify_func(headers, body)
            elif params == 2:
                notify_func(headers)
            else:
                notify_func()
コード例 #3
0
    def __notify(self, frame_type, headers=None, body=None):
        """
        Utility function for notifying listeners of incoming and outgoing messages
        
        \param frame_type the type of message
        
        \param headers the map of headers associated with the message
        
        \param body the content of the message
        """
        for listener in self.__listeners.values():
            if not hasattr(listener, 'on_%s' % frame_type):
                log.debug('listener %s has no method on_%s' %
                          (listener, frame_type))
                continue

            if frame_type == 'connecting':
                listener.on_connecting(self.__current_host_and_port)
                continue

            notify_func = getattr(listener, 'on_%s' % frame_type)
            params = backward.get_func_argcount(notify_func)
            if params >= 3:
                notify_func(headers, body)
            elif params == 2:
                notify_func(headers)
            else:
                notify_func()
コード例 #4
0
ファイル: connect.py プロジェクト: jesobreira/casanova
    def __notify(self, frame_type, headers=None, body=None):
        """
        Utility function for notifying listeners of incoming and outgoing messages
        
        \param frame_type the type of message
        
        \param headers the map of headers associated with the message
        
        \param body the content of the message
        """
        if frame_type == 'receipt':
            # logic for wait-on-receipt notification
            self.__send_wait_condition.acquire()
            self.__receipts[headers['receipt-id']] = None
            self.__send_wait_condition.notify()
            self.__send_wait_condition.release()

        for listener in self.__listeners.values():
            if not hasattr(listener, 'on_%s' % frame_type):
                log.debug('listener %s has no method on_%s' %
                          (listener, frame_type))
                continue

            if frame_type == 'connecting':
                listener.on_connecting(self.__current_host_and_port)
                continue

            notify_func = getattr(listener, 'on_%s' % frame_type)
            params = backward.get_func_argcount(notify_func)
            if params >= 3:
                notify_func(headers, body)
            elif params == 2:
                notify_func(headers)
            else:
                notify_func()