Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Purpose of WebsocketRPCEndpoint.on_connect #39

Closed
5p4k opened this issue Jul 22, 2024 · 4 comments · Fixed by #40
Closed

Purpose of WebsocketRPCEndpoint.on_connect #39

5p4k opened this issue Jul 22, 2024 · 4 comments · Fixed by #40

Comments

@5p4k
Copy link
Contributor

5p4k commented Jul 22, 2024

I was trying out the package and I was going to inherit from WebsocketRPCEndpoint and override on_connect.

async def on_connect(self, channel, websocket):

However in my test example it's never called, and in fact, it seems like it's never referred to at any point; the handlers in the private member _on_connect are passed directly to RpcChannel:
channel.register_connect_handler(self._on_connect)

So wonder what is the purpose of on_connect? Is that supposed to be called externally by e.g. FastAPI? Was it supposed to be passed to register_connect_handler?

@orweis
Copy link
Contributor

orweis commented Jul 29, 2024

@5p4k
Copy link
Contributor Author

5p4k commented Jul 29, 2024

The purpose of the on_connect argument of __init__ (which the example you linked makes use of) is clear.

I was wondering about the on_connect method of WebsocketRPCEndpoint. It creates a task that executes self._on_connect handlers, but it's never called and it duplicates the functionality already offered by RpcChannel.on_handler_event. It looks like it's not called by anything.

@orweis
Copy link
Contributor

orweis commented Jul 29, 2024

Yes, you seem to be right.
I guess it's seem artifact missed in a refactor - this part is 4 years old.

@orweis
Copy link
Contributor

orweis commented Jul 29, 2024

Would you like to open a PR to fix this? :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants