Initial commit

This commit is contained in:
Michael Woods
2025-01-03 00:34:48 -05:00
commit 7738b73ff3
7 changed files with 85 additions and 0 deletions

View File

View File

@@ -0,0 +1,2 @@
class Client:
pass

View File

@@ -0,0 +1,34 @@
from pe.connect import Connection
from threading import Lock
from msgpack import Unpacker
class PacketServerConnection(Connection):
connection_subscribers = []
receive_subscribers = []
def __init__(self, port, call_from, call_to, incoming=False):
super().__init__(port, call_from, call_to, incoming=incoming)
# Now perform any initialization of your own that you might need
self.data = Unpacker()
self.data_lock = Lock()
def connected(self):
print("connected")
for fn in PacketServerConnection.connection_subscribers:
fn(self)
def disconnected(self):
pass
def data_received(self, pid, data):
with self.data_lock:
self.data.feed(data)
for fn in PacketServerConnection.receive_subscribers:
fn(self)
@classmethod
def query_accept(cls, port, call_from, call_to):
return True

View File

@@ -0,0 +1,22 @@
import pe
from ..common import PacketServerConnection
import ax25
from configparser import ConfigParser
from pathlib import Path
import ZODB, transaction
class Server:
def __init__(self, pe_server: str, port: int, server_callsign: str, data_dir: str = None):
if not ax25.Address.valid_call(server_callsign):
raise ValueError(f"Provided callsign '{server_callsign}' is invalid.")
self.callsign = server_callsign
self.pe_server = pe_server
self.pe_port = port
if data_dir:
if Path.is_dir(data_dir):
self.home_dir = data_dir
def server_receiver(self, conn: PacketServerConnection):
pass
pass