2024-07-03 23:29:26 +09:00
|
|
|
import abc
|
2024-07-04 16:07:12 +09:00
|
|
|
|
|
|
|
from mixnet.framework.framework import Framework
|
2024-07-03 23:29:26 +09:00
|
|
|
|
|
|
|
|
|
|
|
class SimplexConnection(abc.ABC):
|
|
|
|
@abc.abstractmethod
|
|
|
|
async def send(self, data: bytes) -> None:
|
|
|
|
pass
|
|
|
|
|
|
|
|
@abc.abstractmethod
|
|
|
|
async def recv(self) -> bytes:
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
class LocalSimplexConnection(SimplexConnection):
|
2024-07-04 16:07:12 +09:00
|
|
|
def __init__(self, framework: Framework):
|
|
|
|
self.queue = framework.queue()
|
2024-07-03 23:29:26 +09:00
|
|
|
|
|
|
|
async def send(self, data: bytes) -> None:
|
|
|
|
await self.queue.put(data)
|
|
|
|
|
|
|
|
async def recv(self) -> bytes:
|
|
|
|
return await self.queue.get()
|