def connection_made(self, transport: transports.Transport): self.peer_name = transport.get_extra_info("peername") self.server_name = transport.get_extra_info("sockname")[1] print(f"Connection from {self.peer_name} -> App Server" if self. server_name == 7077 else f"Connection from {self.peer_name} -> Cmd Server") self.transport = transport
def connection_made(self, transport: Transport) -> None: self.peername = '{}:{}'.format(*transport.get_extra_info('peername')) self.transport = transport # 设置 TCP_NODELAY sock = transport.get_extra_info('socket') sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) logger.info(f'来自 {self.peername} 的连接已建立')
async def writer(self, transport: Transport) -> None: try: while True: message = f"server message: {time.time()}" response = WebsocketResponse(message).response() transport.write(response) await asyncio.sleep(5) except Exception as exc: log.error(exc) transport.close()
def connection_made(self, transport: transports.Transport) -> None: self.transport = transport addr, port = transport.get_extra_info("peername") self.details.host_address = addr self.details.host_port = port out_buffer = bytearray() self.telnet.start(out_buffer) self.running = True self.transport.write(out_buffer)
def connection_made(self, transport: Transport) -> None: """ An oblique client has connected. :param transport: transport supplied by asyncio :return: None """ self.peername = transport.get_extra_info("peername") self.log.info("Client connected from {}:{}".format(*self.peername)) self.transport = transport
def connection_made(self, transport: transports.Transport = None) -> None: if transport: self.transport = transport self.peername = transport.get_extra_info("peername") self.log.info("Connection made to %s:%d", self.peername[0], self.peername[1]) if self._keypair: self.log.info("Automatically authenticating: %s@%s", self._user_agent, self._version) self.send_packet( AdminJoin.create(name=self._user_agent, version=self._version))
def send_history(self, transport: transports.Transport): msg_count = len(self.history_storage) if msg_count > 0: transport.write( f"\033[36mLast {msg_count} message(s):\033[0m\n".encode()) for msg in self.history_storage: transport.write(f"{msg}\n".encode()) transport.write("\033[36m↓↓↓↓↓ New messages ↓↓↓↓↓\033[0m\n".encode())
def connection_made(self, transport: transports.Transport) -> None: self.transport = transport self.address = transport.get_extra_info("peername")[0] self.port = transport.get_extra_info("peername")[1] log.debug("Connection made %s:%s", self.address, self.port)