parameters: (self)
docstring: Bridge clients with server
          :return:
docstring_summary: Bridge clients with server
          :return:
docstring_tokens: Bridge clients with server : return :
function: def bridge(self):
          """
          Bridge clients with server
          :return:
          """
          logger.info("Start bridge session: {}".format(self.id))
          self.pre_bridge()
          self.sel.register(self.client, selectors.EVENT_READ)
          self.sel.register(self.server, selectors.EVENT_READ)
          self.sel.register(self.stop_evt, selectors.EVENT_READ)
          self.sel.register(self.client.change_size_evt, selectors.EVENT_READ)
          while not self.is_finished:
              events = self.sel.select(timeout=60)
              if self.client.closed:
                  break
              if self.server.closed:
                  break
              for sock in [key.fileobj for key, _ in events]:
                  data = sock.recv(BUF_SIZE)
                  if sock == self.server:
                      if len(data) == 0:
                          msg = "Server close the connection"
                          logger.info(msg)
                          self.is_finished = True
                          break
  
                      self.date_last_active = datetime.datetime.utcnow()
                      for watcher in [self.client] + self._watchers + self._sharers:
                          watcher.send(data)
                  elif sock == self.client:
                      if len(data) == 0:
                          msg = "Client close the connection: {}".format(self.client)
                          logger.info(msg)
                          for watcher in self._watchers + self._sharers:
                              watcher.send(msg.encode("utf-8"))
                          self.is_finished = True
                          break
                      self.server.send(data)
                  elif sock == self.stop_evt:
                      self.is_finished = True
                      break
                  elif sock == self.client.change_size_evt:
                      self.resize_win_size()
          logger.debug("Session stop event set: {}".format(self.id))
function_tokens: def bridge ( self ) : logger . info ( "Start bridge session: {}" . format ( self . id ) ) self . pre_bridge ( ) self . sel . register ( self . client , selectors . EVENT_READ ) self . sel . register ( self . server , selectors . EVENT_READ ) self . sel . register ( self . stop_evt , selectors . EVENT_READ ) self . sel . register ( self . client . change_size_evt , selectors . EVENT_READ ) while not self . is_finished : events = self . sel . select ( timeout = 60 ) if self . client . closed : break if self . server . closed : break for sock in [ key . fileobj for key , _ in events ] : data = sock . recv ( BUF_SIZE ) if sock == self . server : if len ( data ) == 0 : msg = "Server close the connection" logger . info ( msg ) self . is_finished = True break self . date_last_active = datetime . datetime . utcnow ( ) for watcher in [ self . client ] + self . _watchers + self . _sharers : watcher . send ( data ) elif sock == self . client : if len ( data ) == 0 : msg = "Client close the connection: {}" . format ( self . client ) logger . info ( msg ) for watcher in self . _watchers + self . _sharers : watcher . send ( msg . encode ( "utf-8" ) ) self . is_finished = True break self . server . send ( data ) elif sock == self . stop_evt : self . is_finished = True break elif sock == self . client . change_size_evt : self . resize_win_size ( ) logger . debug ( "Session stop event set: {}" . format ( self . id ) )