File tree Expand file tree Collapse file tree 6 files changed +30
-25
lines changed Expand file tree Collapse file tree 6 files changed +30
-25
lines changed Original file line number Diff line number Diff line change 77 import warnings
88 warnings .warn ("Importing 'jupyter_rtc_core' outside a proper installation." )
99 __version__ = "dev"
10- from .handlers import setup_handlers
10+
11+ from .app import RtcExtensionApp
1112
1213
1314def _jupyter_labextension_paths ():
@@ -19,18 +20,6 @@ def _jupyter_labextension_paths():
1920
2021def _jupyter_server_extension_points ():
2122 return [{
22- "module" : "jupyter_rtc_core"
23+ "module" : "jupyter_rtc_core" ,
24+ "app" : RtcExtensionApp
2325 }]
24-
25-
26- def _load_jupyter_server_extension (server_app ):
27- """Registers the API handler to receive HTTP requests from the frontend extension.
28-
29- Parameters
30- ----------
31- server_app: jupyterlab.labapp.LabApp
32- JupyterLab application instance
33- """
34- setup_handlers (server_app .web_app )
35- name = "jupyter_rtc_core"
36- server_app .log .info (f"Registered { name } server extension" )
Original file line number Diff line number Diff line change 1+ from jupyter_server .extension .application import ExtensionApp
2+
3+ from .handlers import RouteHandler
4+ from .websockets import GlobalAwarenessWebsocket , YRoomWebsocket
5+
6+ class RtcExtensionApp (ExtensionApp ):
7+ name = "jupyter_rtc_core"
8+ handlers = [
9+ # dummy handler that verifies the server extension is installed;
10+ # this can be deleted prior to initial release.
11+ (r"jupyter-rtc-core/get-example/?" , RouteHandler ),
12+ # global awareness websocket
13+ (r"api/collaboration/room/JupyterLab:globalAwareness/?" , GlobalAwarenessWebsocket ),
14+ # ydoc websocket
15+ (r"api/collaboration/room/(.*)" , YRoomWebsocket )
16+ ]
Original file line number Diff line number Diff line change 11import json
22
33from jupyter_server .base .handlers import APIHandler
4- from jupyter_server .utils import url_path_join
54import tornado
65
76class RouteHandler (APIHandler ):
@@ -13,12 +12,3 @@ def get(self):
1312 self .finish (json .dumps ({
1413 "data" : "This is /jupyter-rtc-core/get-example endpoint!"
1514 }))
16-
17-
18- def setup_handlers (web_app ):
19- host_pattern = ".*$"
20-
21- base_url = web_app .settings ["base_url" ]
22- route_pattern = url_path_join (base_url , "jupyter-rtc-core" , "get-example" )
23- handlers = [(route_pattern , RouteHandler )]
24- web_app .add_handlers (host_pattern , handlers )
Original file line number Diff line number Diff line change 1+ from .global_awareness_ws import GlobalAwarenessWebsocket
2+ from .yroom_ws import YRoomWebsocket
Original file line number Diff line number Diff line change 1+ from tornado .websocket import WebSocketHandler
2+
3+ class GlobalAwarenessWebsocket (WebSocketHandler ):
4+ pass
Original file line number Diff line number Diff line change 1+ from tornado .websocket import WebSocketHandler
2+
3+ class YRoomWebsocket (WebSocketHandler ):
4+ pass
You can’t perform that action at this time.
0 commit comments