dddp/websocket.py
def dispatch(self, msg, kwargs):
        """Dispatch msg to appropriate recv_foo handler."""
        # enforce calling 'connect' first
        if self.connection is None and msg != 'connect':
            self.reply('error', reason='Must connect first')
            return
        if msg == 'method':
            if (
                'method' not in kwargs
            ) or (
                'id' not in kwargs
            ):
                self.reply(
                    'error', error=400, reason='Malformed method invocation',
                )
                return

        # lookup method handler
        try:
            handler = getattr(self, 'recv_%s' % msg)
        except (AttributeError, UnicodeEncodeError):
            raise MeteorError(404, 'Method not found')

        # validate handler arguments
        validate_kwargs(handler, kwargs)

        # dispatch to handler
        handler(**kwargs)
def dispatch(self, msg, kwargs):
        # enforce calling 'connect' first
        if self.connection is None and msg != 'connect':
            self.reply('error', reason='Must connect first')
            return
        if msg == 'method':
            if (
                'method' not in kwargs
            ) or (
                'id' not in kwargs
            ):
                self.reply(
                    'error', error=400, reason='Malformed method invocation',
                )
                return

        # lookup method handler
        try:
            handler = getattr(self, 'recv_%s' % msg)
        except (AttributeError, UnicodeEncodeError):
            raise MeteorError(404, 'Method not found')

        # validate handler arguments
        validate_kwargs(handler, kwargs)

        # dispatch to handler
        handler(**kwargs)
def dispatch ( self , msg , kwargs ) : # enforce calling 'connect' first if self . connection is None and msg != 'connect' : self . reply ( 'error' , reason = 'Must connect first' ) return if msg == 'method' : if ( 'method' not in kwargs ) or ( 'id' not in kwargs ) : self . reply ( 'error' , error = 400 , reason = 'Malformed method invocation' , ) return # lookup method handler try : handler = getattr ( self , 'recv_%s' % msg ) except ( AttributeError , UnicodeEncodeError ) : raise MeteorError ( 404 , 'Method not found' ) # validate handler arguments validate_kwargs ( handler , kwargs ) # dispatch to handler handler ( * * kwargs )
Dispatch msg to appropriate recv_foo handler.
Dispatch msg to appropriate recv_foo handler .