def METHOD_NAME(self, event: events.Event) -> layer.CommandGenerator[None]:
    if isinstance(event, TcpMessageInjected):
        # we just spoof that we received data here and then process that regularly.
        event = events.DataReceived(
            self.context.client
            if event.message.from_client
            else self.context.server,
            event.message.content,
        )
    assert isinstance(event, events.ConnectionEvent)
    from_client = event.connection == self.context.client
    send_to: Connection
    if from_client:
        send_to = self.context.server
    else:
        send_to = self.context.client
    if isinstance(event, events.DataReceived):
        if self.flow:
            tcp_message = tcp.TCPMessage(from_client, event.data)
            self.flow.messages.append(tcp_message)
            yield TcpMessageHook(self.flow)
            yield commands.SendData(send_to, tcp_message.content)
        else:
            yield commands.SendData(send_to, event.data)
    elif isinstance(event, events.ConnectionClosed):
        all_done = not (
            (self.context.client.state & ConnectionState.CAN_READ)
            or (self.context.server.state & ConnectionState.CAN_READ)
        )
        if all_done:
            self._handle_event = self.done
            if self.context.server.state is not ConnectionState.CLOSED:
                yield commands.CloseConnection(self.context.server)
            if self.context.client.state is not ConnectionState.CLOSED:
                yield commands.CloseConnection(self.context.client)
            if self.flow:
                yield TcpEndHook(self.flow)
                self.flow.live = False
        else:
            yield commands.CloseTcpConnection(send_to, half_close=True)
    else:
        raise AssertionError(f"Unexpected event: {event}")