|
|
|
@ -18,18 +18,18 @@
|
|
|
|
|
###############################################################################
|
|
|
|
|
|
|
|
|
|
import struct
|
|
|
|
|
from rich.console import Console
|
|
|
|
|
import asyncio
|
|
|
|
|
from rich.console import Console
|
|
|
|
|
from notification_server.notification_saver import NotificationSaver
|
|
|
|
|
from notification_server.timestamp import Timestamp
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Server:
|
|
|
|
|
BUFFER_SIZE = 1024
|
|
|
|
|
NOTIFICATION_DIR = 'notifications'
|
|
|
|
|
NOTIFICATION_DIR = None
|
|
|
|
|
console = Console()
|
|
|
|
|
|
|
|
|
|
def __init__(self, ip: str, port: int, producer_port: int, notification_dir: str = 'notifications'):
|
|
|
|
|
def __init__(self, ip: str, port: int, producer_port: int, notification_dir: str | None = None):
|
|
|
|
|
self.NOTIFICATION_DIR = notification_dir
|
|
|
|
|
self.__client_socket = None
|
|
|
|
|
self.__producer_socket = None
|
|
|
|
@ -88,8 +88,9 @@ class Server:
|
|
|
|
|
self.console.print(f"[yellow b][INFO][/][#8abeb7 b][{now}][/] The producer ({addr[0]}:{addr[1]}) finished.")
|
|
|
|
|
break
|
|
|
|
|
|
|
|
|
|
now = Timestamp.now()
|
|
|
|
|
NotificationSaver.save_notification(self.NOTIFICATION_DIR, title, message, now)
|
|
|
|
|
if not self.NOTIFICATION_DIR is None:
|
|
|
|
|
now = Timestamp.now()
|
|
|
|
|
NotificationSaver.save_notification(self.NOTIFICATION_DIR, title, message, now)
|
|
|
|
|
|
|
|
|
|
await self.broadcast_message(title)
|
|
|
|
|
await self.broadcast_message(message)
|
|
|
|
|