code: def _handle_connect(self, environ, start_response, transport, b64=False):
          
          if self.start_service_task:
              # start the service task to monitor connected clients
              self.start_service_task = False
              self.start_background_task(self._service_task)
  
          sid = self._generate_id()
          s = socket.Socket(self, sid)
          self.sockets[sid] = s
  
          pkt = packet.Packet(
              packet.OPEN, {'sid': sid,
                            'upgrades': self._upgrades(sid, transport),
                            'pingTimeout': int(self.ping_timeout * 1000),
                            'pingInterval': int(self.ping_interval * 1000)})
          s.send(pkt)
  
          ret = self._trigger_event('connect', sid, environ, run_async=False)
          if ret is False:
              del self.sockets[sid]
              self.logger.warning('Application rejected connection')
              return self._unauthorized()
  
          if transport == 'websocket':
              ret = s.handle_get_request(environ, start_response)
              if s.closed:
                  # websocket connection ended, so we are done
                  del self.sockets[sid]
              return ret
          else:
              s.connected = True
              headers = None
              if self.cookie:
                  headers = [('Set-Cookie', self.cookie + '=' + sid)]
              try:
                  return self._ok(s.poll(), headers=headers, b64=b64)
              except exceptions.QueueEmpty:
                  return self._bad_request()
docs: Handle a client connection request.