def __init__(self, socket, addr, server): self.server=server try: StreamRequestHandler.__init__(self, socket, addr, server) except: self.keep_alive = False return
def __init__(self, *args, **kwargs): self._logger = get_logger() self._availiable_hosts = {} self._peer_socks_lock = threading.Lock() self._peer_socket = {} self._mqtt_client = mqtt_client() StreamRequestHandler.__init__(self, *args, **kwargs)
def __init__(self, socket, addr, server): self.server = server StreamRequestHandler.__init__(self, socket, addr, server) server_thread = threading.Thread(target=self.connect) # Exit the server thread when the main thread terminates server_thread.daemon = True server_thread.start()
def __init__(self, sock: socket, addr: str, server: WebsocketServer): self.server = server self.keep_alive = True self.handshake_done = False self.valid_client = False self.sock = sock self.id = -1 StreamRequestHandler.__init__(self, sock, addr, server)
def finish(self): if self.is_websocket: if not self.finished: self.finished = True StreamRequestHandler.finish(self) self.server._client_left(self) else: StreamRequestHandler.finish(self)
def setup(self): if self.server.use_ssl: self.connection = self.request self.rfile = socket.SocketIO(self.request, "rb") self.wfile = socket.SocketIO(self.request, "wb") else: StreamRequestHandler.setup(self) self.keep_alive = True self.handshake_done = False self.valid_client = False
def setup(self): StreamRequestHandler.setup(self) self.is_websocket = self.rfile.peek().find(b'Upgrade: websocket') != -1 if self.is_websocket: self.keep_alive = True self.finished = False self.handshake_done = False self.valid_client = False self.bytes_buffer = bytearray()
def __init__(self, request: socket, client_address: Tuple, server: BaseServer) -> None: """ Creates a new handler for the given client request :param request: Client socket requesting :param client_address: Client address :param server: Server requested """ self.server: BaseServer = server self.database: Database = server.database StreamRequestHandler.__init__(self, request, client_address, server)
def __init__(self, request, client_address, server): self.queue = Queue() self.data = {} self.response = None self.logger = logging.getLogger(Server.__name__.lower()) self.log_messages = { self.handle.__name__: { MSG_RECEIVE: { SUCCESSFUL_MSG_KEY: SERVER_CLIENT_RECV_SUCC_MSG, UNSUCCESSFUL_MSG_KEY: SERVER_CLIENT_RECV_UNSUCC_MSG }, MSG_SEND: { SUCCESSFUL_MSG_KEY: SERVER_CLIENT_SEND_SUCC_MSG, UNSUCCESSFUL_MSG_KEY: SERVER_CLIENT_SEND_UNSUCC_MSG }, } } StreamRequestHandler.__init__(self, request, client_address, server)
def __init__(self, request, client_address, server): StreamRequestHandler.__init__(self, request, client_address, server)
def __call__(self, request, client_address, server): handler = RequestHandler(self.ip, self.servo) StreamRequestHandler.__init__(handler, request, client_address, server)
def finish(self): LOG.info("Remote probe client disconnected (%s from port %i)", self._client_domain, self.client_address[1]) self._session = None StreamRequestHandler.finish(self)
def setup(self): StreamRequestHandler.setup(self) threading.current_thread().setName(f"handler-{self.server.display_name}")
def __init__(self, request, client_address, server, socket_server): self.socket_server = socket_server self.responder = DispatcherResponder( self.socket_server.protocols, self.socket_server.avro_proxy_factory) StreamRequestHandler.__init__(self, request, client_address, server)
def setup(self): # Do a DNS lookup on the client. try: info = socket.gethostbyaddr(self.client_address[0]) self._client_domain = info[0] except socket.herror: self._client_domain = self.client_address[0] LOG.info("Remote probe client connected (%s from port %i)", self._client_domain, self.client_address[1]) # Get the session and probe we're serving from the server. self._session = self.server.session self._probe = self.server.probe # Give the probe a session if it doesn't have one, in case it needs to access settings. # TODO: create a session proxy so client-side options can be accessed if self._probe.session is None: self._probe.session = self._session # Dict to store handles for AP memory interfaces. self._next_ap_memif_handle = 0 self._ap_memif_handles = {} # Create the request handlers dict here so we can reference bound probe methods. self._REQUEST_HANDLERS = { # Command Handler Arg count 'hello': (self._request__hello, 1), 'readprop': (self._request__read_property, 1), 'open': (self._probe.open, 0), # 'open' 'close': (self._probe.close, 0), # 'close' 'lock': (self._probe.lock, 0), # 'lock' 'unlock': (self._probe.unlock, 0), # 'unlock' 'connect': (self._request__connect, 1), # 'connect', protocol:str 'disconnect': (self._probe.disconnect, 0), # 'disconnect' 'swj_sequence': (self._probe.swj_sequence, 2), # 'swj_sequence', length:int, bits:int 'swd_sequence': ( self._probe.swd_sequence, 1 ), # 'swd_sequence', sequences:List[Union[Tuple[int], Tuple[int, int]]] -> Tuple[int, List[bytes]] 'jtag_sequence': ( self._probe.jtag_sequence, 4 ), # 'jtag_sequence', cycles:int, tms:int, read_tdo:bool, tdi:int -> Union[None, int] 'set_clock': (self._probe.set_clock, 1), # 'set_clock', freq:int 'reset': (self._probe.reset, 0), # 'reset' 'assert_reset': (self._probe.assert_reset, 1), # 'assert_reset', asserted:bool 'is_reset_asserted': (self._probe.is_reset_asserted, 0), # 'is_reset_asserted' 'flush': (self._probe.flush, 0), # 'flush' 'read_dp': (self._probe.read_dp, 1), # 'read_dp', addr:int -> int 'write_dp': (self._probe.write_dp, 2), # 'write_dp', addr:int, data:int 'read_ap': (self._probe.read_ap, 1), # 'read_ap', addr:int -> int 'write_ap': (self._probe.write_ap, 2), # 'write_ap', addr:int, data:int 'read_ap_multiple': (self._probe.read_ap_multiple, 2), # 'read_ap_multiple', addr:int, count:int -> List[int] 'write_ap_multiple': (self._probe.write_ap_multiple, 2), # 'write_ap_multiple', addr:int, data:List[int] 'get_memory_interface_for_ap': ( self._request__get_memory_interface_for_ap, 2 ), # 'get_memory_interface_for_ap', ap_address_version:int, ap_nominal_address:int -> handle:int|null 'swo_start': (self._probe.swo_start, 1), # 'swo_start', baudrate:int 'swo_stop': (self._probe.swo_stop, 0), # 'swo_stop' 'swo_read': (self._request__swo_read, 0), # 'swo_read' -> List[int] 'read_mem': (self._request__read_mem, 3), # 'read_mem', handle:int, addr:int, xfer_size:int -> int 'write_mem': (self._request__write_mem, 4), # 'write_mem', handle:int, addr:int, value:int, xfer_size:int 'read_block32': ( self._request__read_block32, 3 ), # 'read_block32', handle:int, addr:int, word_count:int -> List[int] 'write_block32': (self._request__write_block32, 3), # 'write_block32', handle:int, addr:int, data:List[int] 'read_block8': ( self._request__read_block8, 3 ), # 'read_block8', handle:int, addr:int, word_count:int -> List[int] 'write_block8': (self._request__write_block8, 3), # 'write_block8', handle:int, addr:int, data:List[int] } # Let superclass do its thing. (Can't use super() here because the superclass isn't derived # from object in Py2.) StreamRequestHandler.setup(self)
def __init__(self, socket, address, server): self.server = server # to access servers top level functionality StreamRequestHandler.__init__(self, socket, address, server)
def __init__(self, socket, addr, server): self.server = server #继承StreamRequestHandler类 StreamRequestHandler.__init__(self, socket, addr, server)
def __init__(self, *args, **kwargs): """Wrapper for StreamRequestHandler.__init__() to log Connection""" StreamRequestHandler.__init__(self, *args, **kwargs) print('Connected client {}:{}'.format(*self.client_address))
def close(self): if not self.finished: self.finished = True StreamRequestHandler.finish(self)
def setup(self): StreamRequestHandler.setup(self) self.connectionAlive = True self.doHandshake = False self.approvedClient = False
def __init__(self, *kargs): StreamRequestHandler.__init__(self, *kargs)
def __init__(self, socket, addr, server): self.server = server self.message_received_callback = None StreamRequestHandler.__init__(self, socket, addr, server)
def __init__(self, socket, addr, server): self.server = server StreamRequestHandler.__init__(self, socket, addr, server) # Socket or request, client addr, server
def finish(self): StreamRequestHandler.finish(self) # ----kong---- self.server.remove_client(self)
def __init__(self, socket, addr, server): self.server = server self.handshake_done = False self.valid_client = False self.keep_alive = True StreamRequestHandler.__init__(self, socket, addr, server)
def setup(self): StreamRequestHandler.setup(self) self.is_connected = True self.handshaked = False self.is_websocket = True
def setup(self): StreamRequestHandler.setup(self) self.conn_keep_alive = True # decides if the connection should be kept alive self.handshake_success = False # WebSocket handshake self.read_key = "" # the key read from WebSocket handshake self.read_upgr_param = False # whether the WebSocket handshake contained the upgrade parameter
def finish(self): self.server._client_remove_(self) StreamRequestHandler.finish(self)
def setup(self): StreamRequestHandler.setup(self) self.keep_alive = True self.handshake_done = False self.valid_client = False
def __init__(self, socket, addr, server): self.server = server self.timeout = 5 StreamRequestHandler.__init__(self, socket, addr, server)