dddp/websocket.py
def ddp_frames_from_message(self, message):
        """Yield DDP messages from a raw WebSocket message."""
        # parse message set
        try:
            msgs = ejson.loads(message)
        except ValueError:
            self.reply(
                'error', error=400, reason='Data is not valid EJSON',
            )
            raise StopIteration
        if not isinstance(msgs, list):
            self.reply(
                'error', error=400, reason='Invalid EJSON messages',
            )
            raise StopIteration
        # process individual messages
        while msgs:
            # pop raw message from the list
            raw = msgs.pop(0)
            # parse message payload
            try:
                data = ejson.loads(raw)
            except (TypeError, ValueError):
                data = None
            if not isinstance(data, dict):
                self.reply(
                    'error', error=400,
                    reason='Invalid SockJS DDP payload',
                    offendingMessage=raw,
                )
            yield data
            if msgs:
                # yield to other greenlets before processing next msg
                gevent.sleep()
def ddp_frames_from_message(self, message):
        # parse message set
        try:
            msgs = ejson.loads(message)
        except ValueError:
            self.reply(
                'error', error=400, reason='Data is not valid EJSON',
            )
            raise StopIteration
        if not isinstance(msgs, list):
            self.reply(
                'error', error=400, reason='Invalid EJSON messages',
            )
            raise StopIteration
        # process individual messages
        while msgs:
            # pop raw message from the list
            raw = msgs.pop(0)
            # parse message payload
            try:
                data = ejson.loads(raw)
            except (TypeError, ValueError):
                data = None
            if not isinstance(data, dict):
                self.reply(
                    'error', error=400,
                    reason='Invalid SockJS DDP payload',
                    offendingMessage=raw,
                )
            yield data
            if msgs:
                # yield to other greenlets before processing next msg
                gevent.sleep()
def ddp_frames_from_message ( self , message ) : # parse message set try : msgs = ejson . loads ( message ) except ValueError : self . reply ( 'error' , error = 400 , reason = 'Data is not valid EJSON' , ) raise StopIteration if not isinstance ( msgs , list ) : self . reply ( 'error' , error = 400 , reason = 'Invalid EJSON messages' , ) raise StopIteration # process individual messages while msgs : # pop raw message from the list raw = msgs . pop ( 0 ) # parse message payload try : data = ejson . loads ( raw ) except ( TypeError , ValueError ) : data = None if not isinstance ( data , dict ) : self . reply ( 'error' , error = 400 , reason = 'Invalid SockJS DDP payload' , offendingMessage = raw , ) yield data if msgs : # yield to other greenlets before processing next msg gevent . sleep ( )
Yield DDP messages from a raw WebSocket message.
Yield DDP messages from a raw WebSocket message .