@@ -15,14 +15,18 @@ class YRoomWebsocket(WebSocketHandler):
1515 yroom : YRoom
1616 room_id : str
1717 client_id : str
18- # TODO: change this. we should pass `self.log` from our
19- # `ExtensionApp` to log messages w/ "RtcCoreExtension" prefix
20- log = logging .Logger ("TEMP" )
2118
2219
2320 @property
2421 def yroom_manager (self ) -> YRoomManager :
2522 return self .settings ["yroom_manager" ]
23+
24+
25+ @property
26+ def log (self ) -> logging .Logger :
27+ # TODO: change this because it's kind of a hack. we should probably set
28+ # up some way to reference our logger from `self.settings`
29+ return self .yroom_manager .log
2630
2731
2832 @property
@@ -35,33 +39,28 @@ def contents_manager(self) -> AsyncContentsManager | ContentsManager:
3539 return self .settings ["contents_manager" ]
3640
3741
38- def prepare (self ):
39- # Bind `room_id` attribute
40- request_path : str = self .request .path
41- self .room_id = request_path .strip ("/" ).split ("/" )[- 1 ]
42+ def open (self , room_id , * _ , ** __ ):
43+ # Bind `room_id` as an instance attribute
44+ self .room_id = room_id
4245
43- # TODO: remove this once globalawareness is implemented
44- if self . room_id == "JupyterLab:globalAwareness" :
46+ # TODO: remove this later
47+ if room_id == "JupyterLab:globalAwareness" :
4548 self .close (1011 )
4649 return
50+
51+ self .log .info (f"ROOM ID: { room_id } " )
52+ self .log .info (f"REQUEST PATH: { self .request .path } " )
4753
4854 # Verify the file ID contained in the room ID points to a valid file.
49- fileid = self . room_id .split (":" )[- 1 ]
55+ fileid = room_id .split (":" )[- 1 ]
5056 path = self .fileid_manager .get_path (fileid )
5157 if not path :
5258 raise HTTPError (404 , f"No file with ID '{ fileid } '." )
53-
54-
55- def open (self , * _ , ** __ ):
56- # TODO: remove this later
57- if self .room_id == "JupyterLab:globalAwareness" :
58- self .close (1011 )
59- return
6059
6160 # Create the YRoom
62- yroom = self .yroom_manager .get_room (self . room_id )
61+ yroom = self .yroom_manager .get_room (room_id )
6362 if not yroom :
64- raise HTTPError (500 , f"Unable to initialize YRoom '{ self . room_id } '." )
63+ raise HTTPError (500 , f"Unable to initialize YRoom '{ room_id } '." )
6564 self .yroom = yroom
6665
6766 # Add self as a client to the YRoom
@@ -71,6 +70,7 @@ def open(self, *_, **__):
7170 def on_message (self , message : bytes ):
7271 # TODO: remove this later
7372 if self .room_id == "JupyterLab:globalAwareness" :
73+ self .close (1011 )
7474 return
7575
7676 # Route all messages to the YRoom for processing
@@ -82,5 +82,7 @@ def on_close(self):
8282 if self .room_id == "JupyterLab:globalAwareness" :
8383 return
8484
85- self .log .info (f"Closed Websocket to client '{ self .client_id } '." )
85+ self .log .info (self .close_code )
86+ self .log .info (self .close_reason )
87+ self .log .info (f"Closed Websocket to client '{ self .client_id } ' on room '{ self .room_id } '." )
8688 self .yroom .clients .remove (self .client_id )
0 commit comments