mirror of
https://github.com/craigerl/aprsd.git
synced 2025-04-21 02:38:42 -04:00
Updated keepalive thread to report client
This patch updates the keepalive thread and the aprsis client and kiss client to report keepalive.
This commit is contained in:
parent
a17b80ddd8
commit
8529f1f8d1
@ -38,7 +38,7 @@ class APRSISClient(base.APRSClient):
|
||||
"connected": self.is_connected,
|
||||
"filter": self.filter,
|
||||
"login_status": self.login_status,
|
||||
"server_keepalive": keepalive,
|
||||
"connection_keepalive": keepalive,
|
||||
"server_string": server_string,
|
||||
"transport": self.transport(),
|
||||
}
|
||||
|
@ -1,3 +1,4 @@
|
||||
import datetime
|
||||
import logging
|
||||
|
||||
import aprslib
|
||||
@ -16,12 +17,17 @@ LOG = logging.getLogger("APRSD")
|
||||
class KISSClient(base.APRSClient):
|
||||
|
||||
_client = None
|
||||
keepalive = datetime.datetime.now()
|
||||
|
||||
def stats(self, serializable=False) -> dict:
|
||||
stats = {}
|
||||
if self.is_configured():
|
||||
keepalive = self.keepalive
|
||||
if serializable:
|
||||
keepalive = keepalive.isoformat()
|
||||
stats = {
|
||||
"connected": self.is_connected,
|
||||
"connection_keepalive": keepalive,
|
||||
"transport": self.transport(),
|
||||
}
|
||||
if self.transport() == client.TRANSPORT_TCPKISS:
|
||||
@ -110,5 +116,9 @@ class KISSClient(base.APRSClient):
|
||||
return self._client
|
||||
|
||||
def consumer(self, callback, blocking=False, immortal=False, raw=False):
|
||||
LOG.info(f"{self.__class__.__name__}.consumer called")
|
||||
self._client.consumer(callback)
|
||||
try:
|
||||
self._client.consumer(callback)
|
||||
self.keepalive = datetime.datetime.now()
|
||||
except Exception as ex:
|
||||
LOG.error(f"Consumer failed {ex}")
|
||||
LOG.error(ex)
|
||||
|
@ -100,7 +100,7 @@ class KeepAliveThread(APRSDThread):
|
||||
# check the APRS connection
|
||||
cl = client_factory.create()
|
||||
cl_stats = cl.stats()
|
||||
ka = cl_stats.get("keepalive", None)
|
||||
ka = cl_stats.get("connection_keepalive", None)
|
||||
if ka:
|
||||
keepalive = timeago.format(ka)
|
||||
else:
|
||||
|
Loading…
Reference in New Issue
Block a user