You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is actually not an issue, but I couldn't find anything in the example app that helps me.
From the example app, I got a hold of the on_connect method of the consumer where I pass the frontend client URL. This URL can be passed directly from apollo client WebSocket link.
asyncdefon_connect(self, payload):
"""New client connection handler."""self.scope['domain'] =payload.get('domain')
print(f"Connected to {self.channel_name}")
In the subscribe and publish methods of my subscriptions, I attempt to attach the domain to the class like below.
defsubscribe(self, info, email):
_scope=info.context._scopedomain=_scope.get('domain')
OnChangeUserAccess.domain=domain# this line doesn't seem to do anything. Works sometimes and fails other times.return [domain]
I then define a class method that broadcasts some change to subscribers.
@classmethoddefbroadcast_change(cls, email):
# email is passed directly to the method at the point of call.domain=cls.domain# Error, OnChangeUserAccess has no property domainuser_access=evaluate_access(domain, email)
cls.broadcast(
group=email,
payload={"user_access": user_access},
)
I could pass the domain directly to the broadcast_change method, but that would just repeat code needlessly in a lot of places, some of them requiring DB access.
My question is, is there a way to get a hold of the scope (or at least the domain) in the broadcast_change method so I can read the domain off of it?
Thanks for any and every help.
The text was updated successfully, but these errors were encountered:
This is actually not an issue, but I couldn't find anything in the example app that helps me.
From the example app, I got a hold of the
on_connect
method of the consumer where I pass the frontend client URL. This URL can be passed directly from apollo client WebSocket link.My subscription class definition starts out as
In the
subscribe
andpublish
methods of my subscriptions, I attempt to attach the domain to the class like below.I then define a class method that broadcasts some change to subscribers.
I could pass the domain directly to the
broadcast_change
method, but that would just repeat code needlessly in a lot of places, some of them requiring DB access.My question is, is there a way to get a hold of the scope (or at least the domain) in the
broadcast_change
method so I can read the domain off of it?Thanks for any and every help.
The text was updated successfully, but these errors were encountered: