mirror of
https://github.com/craigerl/aprsd.git
synced 2025-09-02 13:17:54 -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,
|
"connected": self.is_connected,
|
||||||
"filter": self.filter,
|
"filter": self.filter,
|
||||||
"login_status": self.login_status,
|
"login_status": self.login_status,
|
||||||
"server_keepalive": keepalive,
|
"connection_keepalive": keepalive,
|
||||||
"server_string": server_string,
|
"server_string": server_string,
|
||||||
"transport": self.transport(),
|
"transport": self.transport(),
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import datetime
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
import aprslib
|
import aprslib
|
||||||
@ -16,12 +17,17 @@ LOG = logging.getLogger("APRSD")
|
|||||||
class KISSClient(base.APRSClient):
|
class KISSClient(base.APRSClient):
|
||||||
|
|
||||||
_client = None
|
_client = None
|
||||||
|
keepalive = datetime.datetime.now()
|
||||||
|
|
||||||
def stats(self, serializable=False) -> dict:
|
def stats(self, serializable=False) -> dict:
|
||||||
stats = {}
|
stats = {}
|
||||||
if self.is_configured():
|
if self.is_configured():
|
||||||
|
keepalive = self.keepalive
|
||||||
|
if serializable:
|
||||||
|
keepalive = keepalive.isoformat()
|
||||||
stats = {
|
stats = {
|
||||||
"connected": self.is_connected,
|
"connected": self.is_connected,
|
||||||
|
"connection_keepalive": keepalive,
|
||||||
"transport": self.transport(),
|
"transport": self.transport(),
|
||||||
}
|
}
|
||||||
if self.transport() == client.TRANSPORT_TCPKISS:
|
if self.transport() == client.TRANSPORT_TCPKISS:
|
||||||
@ -110,5 +116,9 @@ class KISSClient(base.APRSClient):
|
|||||||
return self._client
|
return self._client
|
||||||
|
|
||||||
def consumer(self, callback, blocking=False, immortal=False, raw=False):
|
def consumer(self, callback, blocking=False, immortal=False, raw=False):
|
||||||
LOG.info(f"{self.__class__.__name__}.consumer called")
|
try:
|
||||||
self._client.consumer(callback)
|
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
|
# check the APRS connection
|
||||||
cl = client_factory.create()
|
cl = client_factory.create()
|
||||||
cl_stats = cl.stats()
|
cl_stats = cl.stats()
|
||||||
ka = cl_stats.get("keepalive", None)
|
ka = cl_stats.get("connection_keepalive", None)
|
||||||
if ka:
|
if ka:
|
||||||
keepalive = timeago.format(ka)
|
keepalive = timeago.format(ka)
|
||||||
else:
|
else:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user