Moved dummyconnection back out of common/__init__.py
This commit is contained in:
@@ -82,21 +82,6 @@ class PacketServerConnection(Connection):
|
|||||||
def query_accept(cls, port, call_from, call_to):
|
def query_accept(cls, port, call_from, call_to):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
class DummyPacketServerConnection(PacketServerConnection):
|
|
||||||
|
|
||||||
def __init__(self, call_from: str, call_to: str, incoming=False):
|
|
||||||
super().__init__(0, call_from, call_to, incoming=incoming)
|
|
||||||
self.sent_data = Unpacker()
|
|
||||||
self._state = ConnectionState.CONNECTED
|
|
||||||
|
|
||||||
@property
|
|
||||||
def state(self):
|
|
||||||
return self._state
|
|
||||||
|
|
||||||
def send_data(self, data: Union[bytes, bytearray]):
|
|
||||||
self.sent_data.feed(data)
|
|
||||||
logging.debug(f"Sender added {data} to self.sent_data.feed")
|
|
||||||
|
|
||||||
|
|
||||||
class Message:
|
class Message:
|
||||||
"""Base class for communication encapsulated in msgpack objects."""
|
"""Base class for communication encapsulated in msgpack objects."""
|
||||||
|
|||||||
20
src/packetserver/common/testing.py
Normal file
20
src/packetserver/common/testing.py
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
from . import PacketServerConnection
|
||||||
|
from pe.connect import ConnectionState
|
||||||
|
from msgpack import Unpacker
|
||||||
|
from typing import Union, Self
|
||||||
|
import logging
|
||||||
|
|
||||||
|
class DummyPacketServerConnection(PacketServerConnection):
|
||||||
|
|
||||||
|
def __init__(self, call_from: str, call_to: str, incoming=False):
|
||||||
|
super().__init__(0, call_from, call_to, incoming=incoming)
|
||||||
|
self.sent_data = Unpacker()
|
||||||
|
self._state = ConnectionState.CONNECTED
|
||||||
|
|
||||||
|
@property
|
||||||
|
def state(self):
|
||||||
|
return self._state
|
||||||
|
|
||||||
|
def send_data(self, data: Union[bytes, bytearray]):
|
||||||
|
self.sent_data.feed(data)
|
||||||
|
logging.debug(f"Sender added {data} to self.sent_data.feed")
|
||||||
Reference in New Issue
Block a user