Skip to content

Commit

Permalink
fix eventsub reconnect (again)
Browse files Browse the repository at this point in the history
  • Loading branch information
IAmTomahawkx committed Sep 9, 2023
1 parent faee30b commit a6c2bbb
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Master
- ext.eventsub
- Bug fixes
- Fix websocket reconnection event.
- Fix another websocket reconnect issue where it tried to decode nonexistent headers.


2.7.0
Expand Down
15 changes: 15 additions & 0 deletions twitchio/ext/eventsub/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,21 @@ class ReconnectEvent(BaseEvent):

__slots__ = ("reconnect_url", "connected_at")

def __init__(
self, client: Union[EventSubClient, EventSubWSClient], _data: Union[str, dict], request: Optional[web.Request]
):
# we skip the super init here because reconnect events dont have headers or subscription information

self._client = client
self._raw_data = _data

if isinstance(_data, str):
data: dict = _loads(_data)
else:
data = _data

self.setup(data["payload"])

def setup(self, data: dict):
self.reconnect_url: str = data["session"]["reconnect_url"]
self.connected_at: datetime.datetime = _parse_datetime(data["session"]["connected_at"])
Expand Down

0 comments on commit a6c2bbb

Please sign in to comment.