Skip to content
This repository was archived by the owner on Dec 20, 2021. It is now read-only.

Commit 274d065

Browse files
committed
Unhandled event hooks
1 parent 6e2bb90 commit 274d065

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

vrcpy/wss.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ def _ws_message(self, ws, message):
2626

2727
if message["type"] in switch:
2828
self._do_function(switch[message["type"]], json.loads(message["content"]))
29+
else:
30+
self._do_function(self._ws_unhandled_event, message["type"], json.loads(message["content"]))
2931

3032
def _ws_error(self, ws, error):
3133
raise WebSocketError(error)
@@ -78,6 +80,9 @@ def on_friend_location(self, friend, world, location, instance):
7880
def on_notification(self, notification):
7981
pass
8082

83+
def on_unhandled_event(self, event, content):
84+
pass
85+
8186
# WS handles
8287

8388
def _ws_friend_online(self, content):
@@ -100,6 +105,9 @@ def _ws_friend_offline(self, content):
100105
def _ws_notification(self, content):
101106
self.on_notification(objects.Notification(self, content))
102107

108+
def _ws_unhandled_event(self, event, content):
109+
self.on_unhandled_event(event, content)
110+
103111
# Internal Client overwrites
104112

105113
def login(self, username, password):
@@ -142,6 +150,9 @@ async def on_friend_location(self, friend, world):
142150
async def on_notification(self, notification):
143151
pass
144152

153+
async def on_unhandled_event(self, event, content):
154+
pass
155+
145156
# WS handles
146157

147158
async def _ws_friend_online(self, content):
@@ -164,6 +175,9 @@ async def _ws_friend_offline(self, content):
164175
async def _ws_notification(self, content):
165176
await self.on_notification(aobjects.Notification(self, content))
166177

178+
async def _ws_unhandled_event(self, event, content):
179+
await self.on_unhandled_event(event, content)
180+
167181
# Internal Client overwrites
168182

169183
async def login(self, username, password):

0 commit comments

Comments
 (0)