Skip to content

Commit

Permalink
feat: client protocol: Add 1s latency before close connection
Browse files Browse the repository at this point in the history
  • Loading branch information
gamecss committed May 8, 2024
1 parent 03767fb commit 4a3cb42
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/pyfsd/protocol/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,10 @@ def send_error(self, errno: int, env: bytes = b"", fatal: bool = False) -> None:
),
)
if fatal:
self.transport.close()
async def kill() -> None:
await asleep(1)
self.transport.close()
task_keeper.add(create_task(kill()))

def send_motd(self) -> None:
"""Send motd to client."""
Expand Down Expand Up @@ -475,7 +478,10 @@ async def handle_add_client(
def handle_remove_client(self, _: Tuple[bytes, ...]) -> HandleResult:
"""Handle remove client request."""
assert self.client is not None
self.transport.close()
async def kill() -> None:
await asleep(1)
self.transport.close()
task_keeper.add(create_task(kill()))
return True, True

@check_packet(17)
Expand Down

0 comments on commit 4a3cb42

Please sign in to comment.