Merge pull request #4 from kerel-fs/feature/+timed_callback

client: Add timed callback
pull/5/head
Meisterschueler 2016-03-29 10:37:28 +02:00
commit 4f66218ef7
2 zmienionych plików z 6 dodań i 2 usunięć

Wyświetl plik

@ -1,5 +1,8 @@
# CHANGELOG
## Unreleased
- aprs client: Added the possibility of a timed callback
## 0.3.0 - 2016-03-18
The repository ogn-python splitted up into two separate repositories:
- python-ogn-client (the repository this Changelog belongs to),

Wyświetl plik

@ -45,14 +45,15 @@ class AprsClient:
except OSError:
self.logger.error('Socket close error', exc_info=True)
def run(self, callback, autoreconnect=False):
def run(self, callback, timed_callback=lambda client: None, autoreconnect=False):
while True:
try:
keepalive_time = time()
while True:
if time() - keepalive_time > settings.APRS_KEEPALIVE_TIME:
self.logger.info('Send keepalive')
self.sock.send('#keepalive'.encode())
self.sock.send('#keepalive\n'.encode())
timed_callback(self)
keepalive_time = time()
# Read packet string from socket