Add the connection message.

main
KKlochko 1 year ago
parent 115e9188b9
commit 9ba1c7554a

@ -2,6 +2,12 @@ from rich.console import Console
from rich.markdown import Markdown from rich.markdown import Markdown
class MessagePrinter: class MessagePrinter:
@staticmethod
def connected(ip, port):
console = Console()
console.print(f'[yellow b][INFO][/] Connected to the server ({ip}:{port}).')
@staticmethod @staticmethod
def print(title: str, message: str): def print(title: str, message: str):
console = Console() console = Console()

@ -35,6 +35,7 @@ class Client:
async def connect(self): async def connect(self):
try: try:
reader, writer = await asyncio.open_connection(self.__ip, self.__port) reader, writer = await asyncio.open_connection(self.__ip, self.__port)
MessagePrinter.connected(self.__ip, self.__port)
except ConnectionRefusedError: except ConnectionRefusedError:
sys.stderr.write("Could not connect to the server. Please, check the ip and the port.\n") sys.stderr.write("Could not connect to the server. Please, check the ip and the port.\n")
sys.exit(1) sys.exit(1)

Loading…
Cancel
Save