Handle non-templated EQ events in client

This commit is contained in:
Salad Dais
2023-12-14 01:23:57 +00:00
parent 0710735546
commit c5ed1cff24

View File

@@ -513,10 +513,20 @@ class HippoClient(BaseClientSessionManager):
continue
polled = await resp.read_llsd()
for event in polled["events"]:
if not self._llsd_serializer.can_handle(event["message"]):
# TODO: handle non-message EQ events
continue
msg = self._llsd_serializer.deserialize(event)
if self._llsd_serializer.can_handle(event["message"]):
msg = self._llsd_serializer.deserialize(event)
else:
# If this isn't a templated message (like some EQ-only events are),
# then we wrap it in a synthetic `Message` so that the API for handling
# both EQ-only and templated message events can be the same. Ick.
msg = Message(event["message"])
if isinstance(event["body"], dict):
msg.add_block(Block("EventData", **event["body"]))
else:
# Shouldn't be any events that have anything other than a dict
# as a body, but just to be sure...
msg.add_block(Block("EventData", Data=event["body"]))
msg.synthetic = True
self.session.message_handler.handle(msg)
self.session.main_region.message_handler.handle(msg)
ack = polled["id"]