28 lines
891 B
Python
28 lines
891 B
Python
#!/usr/bin/env python3
|
|
# -*- coding: utf-8 -*-
|
|
|
|
from typing import Any, Self, Optional, Sequence
|
|
from abc import ABC, abstractmethod
|
|
from Interfaces.Application.AnPInterface import AnPInterface
|
|
from Application.Event import Event
|
|
|
|
class WebSocketServersAbstract(ABC):
|
|
|
|
def __init__(self:Self, anp:AnPInterface, inputs:Optional[dict[str, Any|None]|Sequence[Any|None]] = None) -> None:
|
|
self.anp:AnPInterface = anp
|
|
self.on_new_client:Event = Event()
|
|
self.on_message:Event = Event()
|
|
self.on_close:Event = Event()
|
|
self.on_error:Event = Event()
|
|
|
|
@abstractmethod
|
|
def start(self:Self) -> None:pass
|
|
|
|
@abstractmethod
|
|
def close(self:Self) -> None:pass
|
|
|
|
@abstractmethod
|
|
def close_client(self:Self, id:int) -> None:pass
|
|
|
|
@abstractmethod
|
|
def send(self:Self, data:Any|None, ids:Optional[int|Sequence[int]] = None) -> None:pass |