@@ -236,6 +236,9 @@ def init_app(self, app):
236
236
# Custom JSON encoder
237
237
app .json_encoder = self .json_encoder
238
238
239
+ # Create socket handler
240
+ self .sockets = Sockets (app )
241
+
239
242
# Add resources, if registered before tying to a Flask app
240
243
if len (self .views ) > 0 :
241
244
for resource , urls , endpoint , kwargs in self .views :
@@ -244,8 +247,7 @@ def init_app(self, app):
244
247
# Create base routes
245
248
self ._create_base_routes ()
246
249
247
- # Create socket handler
248
- self .sockets = Sockets (app )
250
+ # Create base sockets
249
251
self ._create_base_sockets ()
250
252
251
253
# Create base events
@@ -448,7 +450,13 @@ def _register_view(self, app, view, *urls, endpoint=None, **kwargs):
448
450
# If we've got no Blueprint, just build a url with no prefix
449
451
rule = self ._complete_url (url , "" )
450
452
# Add the url to the application or blueprint
451
- app .add_url_rule (rule , view_func = resource_func , ** kwargs )
453
+ app .add_url_rule (rule , view_func = resource_func , endpoint = endpoint , ** kwargs )
454
+ # Add to self.sockets so that the socket middleware may
455
+ # intercept the connection
456
+ if hasattr (view , "websocket" ):
457
+ self .sockets .add_url_rule (
458
+ rule , view_func = resource_func , endpoint = endpoint
459
+ )
452
460
453
461
# There might be a better way to do this than _rules_by_endpoint,
454
462
# but I can't find one so this will do for now. Skipping PYL-W0212
0 commit comments