From af0089209ed8ea0a5ce29711d81c655b6b12bf94 Mon Sep 17 00:00:00 2001 From: KKlochko Date: Tue, 12 Dec 2023 15:55:02 +0200 Subject: [PATCH] Add the server and the entry point. --- notification_client/client.py | 28 ++++++++++++++++++++++++++++ notification_client/main.py | 8 ++++++++ 2 files changed, 36 insertions(+) create mode 100644 notification_client/client.py create mode 100644 notification_client/main.py diff --git a/notification_client/client.py b/notification_client/client.py new file mode 100644 index 0000000..eda0f8c --- /dev/null +++ b/notification_client/client.py @@ -0,0 +1,28 @@ +import asyncio +import struct + + +class Client: + BUFFER_SIZE = 1024 + + def __init__(self, ip: str, port: int): + self.__ip = ip + self.__port = port + + async def connect(self): + reader, writer = await asyncio.open_connection(self.__ip, self.__port) + await self.handle(reader, writer) + + async def handle(self, reader, writer): + try: + while True: + size, = struct.unpack('