klippy_connection: improve subscription request handling
If the connection requesting the subscription already had an outstanding subscription, remove it before processing. This prevents immediate status updates from being pushed to the requesting connection. Don't add connections to the dictionary of subscribed connections if the request is an empty object, as this is a request to unsubscribe from all objects. Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
parent
71ab2fb80e
commit
b8388db18d
@ -624,6 +624,8 @@ class KlippyConnection:
|
||||
raise self.server.error(
|
||||
"No connection associated with subscription request"
|
||||
)
|
||||
# if the connection has an existing subscription pop it off
|
||||
self.subscriptions.pop(conn, None)
|
||||
requested_sub: Subscription = args.get('objects', {})
|
||||
all_subs: Subscription = dict(requested_sub)
|
||||
# Build the subscription request from a superset of all client subscriptions
|
||||
@ -695,7 +697,8 @@ class KlippyConnection:
|
||||
if obj_name not in all_status:
|
||||
del self.subscription_cache[obj_name]
|
||||
result['status'] = pruned_status
|
||||
self.subscriptions[conn] = requested_sub
|
||||
if requested_sub:
|
||||
self.subscriptions[conn] = requested_sub
|
||||
return result
|
||||
|
||||
async def _request_standard(
|
||||
|
Loading…
x
Reference in New Issue
Block a user