File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22import asyncio
33import sys
44import os
5+ import json
56sys .path .append (os .path .abspath (os .path .join (os .path .dirname (__file__ ), '..' , '..' ))) # Add the project root to sys.path
67from ringcentral .websocket .events import WebSocketEvents
78from ringcentral import SDK
@@ -19,6 +20,10 @@ def on_ws_created(web_socket_client):
1920 print ("\n New WebSocket connection created:" )
2021 print (web_socket_client .get_connection_info ())
2122
23+ def on_message (message ):
24+ print ("\n WebSocket message:\n " )
25+ print (json .loads (message ))
26+
2227async def main ():
2328 load_dotenv (override = True )
2429 sdk = SDK (
@@ -31,6 +36,7 @@ async def main():
3136
3237 try :
3338 web_socket_client = sdk .create_web_socket_client ()
39+ web_socket_client .on (WebSocketEvents .receiveMessage , on_message )
3440 web_socket_client .on (WebSocketEvents .connectionCreated , on_ws_created )
3541 web_socket_client .on (WebSocketEvents .subscriptionCreated , on_sub_created )
3642 web_socket_client .on (WebSocketEvents .receiveSubscriptionNotification , on_notification )
You can’t perform that action at this time.
0 commit comments