def open(self, uuid): if self.request.headers['Origin'] != 'http://%s' % ( self.request.headers['Host']): self.close() return self.uuid = uuid if isinstance(self.uuid, bytes): self.uuid = self.uuid.decode('utf-8') if self.uuid in websockets.uuids: log.warn( 'Websocket already opened for %s. Closing previous one' % self.uuid) websockets.send(self.uuid, 'Die') websockets.close(uuid) if self.uuid not in sockets.uuids: log.warn( 'Websocket opened for %s with no correponding socket' % self.uuid) sockets.send(self.uuid, 'Die') self.close() return log.info('Websocket opened for %s' % self.uuid) websockets.add(self.uuid, self)
def on_close(stream, uuid): # None if the user closed the window log.info('uuid %s closed' % uuid) websockets.send(uuid, 'Die') websockets.close(uuid) websockets.remove(uuid) sockets.remove(uuid)
def on_open(self, uuid): self.uuid = uuid if isinstance(self.uuid, bytes): self.uuid = self.uuid.decode('utf-8') if self.uuid in websockets.uuids: log.warn( 'Websocket already opened for %s. Closing previous one' % self.uuid ) websockets.send(self.uuid, 'Die') websockets.close(uuid) if self.uuid not in sockets.uuids: log.warn( 'Websocket opened for %s with no correponding socket' % self.uuid ) sockets.send(self.uuid, 'Die') self.close() return log.info('Websocket opened for %s' % self.uuid) websockets.add(self.uuid, self)
def open(self, uuid): if self.request.headers['Origin'] != 'http://%s' % ( self.request.headers['Host']): self.close() return self.uuid = uuid if isinstance(self.uuid, bytes): self.uuid = self.uuid.decode('utf-8') if self.uuid in websockets.uuids: log.warn('Websocket already opened for %s. Closing previous one' % self.uuid) websockets.send(self.uuid, 'Die') websockets.close(uuid) if self.uuid not in sockets.uuids: log.warn('Websocket opened for %s with no correponding socket' % self.uuid) sockets.send(self.uuid, 'Die') self.close() return log.info('Websocket opened for %s' % self.uuid) websockets.add(self.uuid, self)
def on_close(stream, uuid): # None if the user closed the window log.info("uuid %s closed" % uuid) if websockets.get(uuid): websockets.send(uuid, "Die") websockets.close(uuid) websockets.remove(uuid) sockets.remove(uuid)
def read_frame(stream, uuid, frame): if frame.decode('utf-8') == 'ServerBreaks': sockets.send(uuid, json.dumps(breakpoints.get())) else: websockets.send(uuid, frame) try: stream.read_bytes(4, partial(read_header, stream, uuid)) except StreamClosedError: log.warn('Closed stream for %s' % uuid)
def read_frame(stream, uuid, frame): decoded_frame = frame.decode("utf-8") if decoded_frame == "ServerBreaks": sockets.send(uuid, json.dumps(breakpoints.get())) elif decoded_frame == "PING": log.info("%s PONG" % uuid) else: websockets.send(uuid, frame) try: stream.read_bytes(4, partial(read_header, stream, uuid)) except StreamClosedError: log.warn("Closed stream for %s" % uuid)
def read_frame(stream, uuid, frame): decoded_frame = frame.decode('utf-8') if decoded_frame == 'ServerBreaks': sockets.send(uuid, json.dumps(breakpoints.get())) elif decoded_frame == 'PING': log.info('%s PONG' % uuid) elif decoded_frame.startswith('UPDATE_FILENAME'): filename = decoded_frame.split('|', 1)[1] sockets.set_filename(uuid, filename) else: websockets.send(uuid, frame) try: stream.read_bytes(4, partial(read_header, stream, uuid)) except StreamClosedError: log.warn('Closed stream for %s' % uuid)