code: async def handler(self, request):
          
  
          def task_done(future):
              self.tasks.remove(future)
              exception = future.exception()
              if exception:
                  log.warning(
                      'While processing message: {0}\nDetails: {1}'.format(
                          exception,
                          traceback.format_exc())
                  )
  
          client = web.WebSocketResponse()
          client_id = id(client)
  
          # upgrade to Websockets
          await client.prepare(request)
  
          log.info('Opening Websocket {0}'.format(id(client)))
          log.debug('Tasks: {0}'.format(self.tasks))
          log.debug('Clients: {0}'.format(self.clients))
  
          try:
              log.debug('Sending root info to {0}'.format(client_id))
              await client.send_json({
                  '$': {'type': CONTROL_MESSAGE, 'monitor': True},
                  'root': self.call_and_serialize(lambda: self.root),
                  'type': self.call_and_serialize(lambda: type(self.root))
              })
              log.debug('Root info sent to {0}'.format(client_id))
          except Exception:
              log.exception('While sending root info to {0}'.format(client_id))
  
          try:
              self.clients[client] = self.send_worker(client)
              # Async receive client data until websocket is closed
              async for msg in client:
                  task = self.loop.create_task(self.process(msg))
                  task.add_done_callback(task_done)
                  self.tasks += [task]
          except Exception:
              log.exception('While reading from socket:')
          finally:
              log.info('Closing WebSocket {0}'.format(id(client)))
              await client.close()
              del self.clients[client]
  
          return client
docs: Receives HTTP request and negotiates up to a Websocket session