Add the connection message.
This commit is contained in:
@@ -21,10 +21,13 @@
|
|||||||
import asyncio
|
import asyncio
|
||||||
import struct
|
import struct
|
||||||
import sys
|
import sys
|
||||||
|
from rich.console import Console
|
||||||
|
from rich.prompt import Prompt
|
||||||
|
|
||||||
|
|
||||||
class ProducerClient:
|
class ProducerClient:
|
||||||
BUFFER_SIZE = 1024
|
BUFFER_SIZE = 1024
|
||||||
|
console = Console()
|
||||||
|
|
||||||
def __init__(self, ip: str, port: int):
|
def __init__(self, ip: str, port: int):
|
||||||
self.__ip = ip
|
self.__ip = ip
|
||||||
@@ -34,6 +37,7 @@ class ProducerClient:
|
|||||||
|
|
||||||
async def connect(self):
|
async def connect(self):
|
||||||
self.reader, self.writer = await asyncio.open_connection(self.__ip, self.__port)
|
self.reader, self.writer = await asyncio.open_connection(self.__ip, self.__port)
|
||||||
|
self.console.print(f'[yellow b][INFO][/] Connected to the server ({self.__ip}:{self.__port}).')
|
||||||
|
|
||||||
async def send(self, message: str):
|
async def send(self, message: str):
|
||||||
self.writer.write(struct.pack('<L', len(message)))
|
self.writer.write(struct.pack('<L', len(message)))
|
||||||
|
|||||||
Reference in New Issue
Block a user