dddp/websocket.py
def on_open(self):
        """Handle new websocket connection."""
        this.request = WSGIRequest(self.ws.environ)
        this.ws = self
        this.send = self.send
        this.reply = self.reply

        self.logger = self.ws.logger
        self.remote_ids = collections.defaultdict(set)

        # `_tx_buffer` collects outgoing messages which must be sent in order
        self._tx_buffer = {}
        # track the head of the queue (buffer) and the next msg to be sent
        self._tx_buffer_id_gen = itertools.cycle(irange(sys.maxint))
        self._tx_next_id_gen = itertools.cycle(irange(sys.maxint))
        # start by waiting for the very first message
        self._tx_next_id = next(self._tx_next_id_gen)

        this.remote_addr = self.remote_addr = \
            '{0[REMOTE_ADDR]}:{0[REMOTE_PORT]}'.format(
                self.ws.environ,
            )
        this.subs = {}
        safe_call(self.logger.info, '+ %s OPEN', self)
        self.send('o')
        self.send('a["{\\"server_id\\":\\"0\\"}"]')
def on_open(self):
        """Handle new websocket connection."""
        this.request = WSGIRequest(self.ws.environ)
        this.ws = self
        this.send = self.send
        this.reply = self.reply

        self.logger = self.ws.logger
        self.remote_ids = collections.defaultdict(set)

        # `_tx_buffer` collects outgoing messages which must be sent in order
        self._tx_buffer = {}
        # track the head of the queue (buffer) and the next msg to be sent
        self._tx_buffer_id_gen = itertools.cycle(irange(sys.maxint))
        self._tx_next_id_gen = itertools.cycle(irange(sys.maxint))
        # start by waiting for the very first message
        self._tx_next_id = next(self._tx_next_id_gen)

        this.remote_addr = self.remote_addr = \
            '{0[REMOTE_ADDR]}:{0[REMOTE_PORT]}'.format(
                self.ws.environ,
            )
        this.subs = {}
        safe_call(self.logger.info, '+ %s OPEN', self)
        self.send('o')
        self.send('a["{\\"server_id\\":\\"0\\"}"]')
Handle new websocket connection.