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

WebSocketClient to receive the message forever. #77

Closed
geohuz opened this issue May 28, 2020 · 2 comments
Closed

WebSocketClient to receive the message forever. #77

geohuz opened this issue May 28, 2020 · 2 comments
Labels
good first issue Good for newcomers

Comments

@geohuz
Copy link

geohuz commented May 28, 2020

I'm not sure how to implement a client "subscribe" to the server and receive message from server forever, currently if I use

let response = waitFor client.call("add", params)

I only get the first response from server, but the scenario is when server accept the subscription then client should receive message from server consequently(streaming data)

@jangko jangko added the good first issue Good for newcomers label Mar 3, 2022
@jangko
Copy link
Contributor

jangko commented Mar 3, 2022

this is actually a good feature to implement. see https://geth.ethereum.org/docs/rpc/pubsub

nim-websock have this ability but currently the websocket session in nim-json-rpc is hidden from the rpc method and also hidden from the app using this server.

exposing all active sessions to the app is easy, but telling the rpc method which ws session is active at the time of the rpc-method execution is a bit tricky. but issue #128 also reveals the possibility to use hidden/magic param/variable to pass the current session without breaking existing rpc method implementation.

@jangko
Copy link
Contributor

jangko commented Jan 7, 2024

This is now supported via onProcessMessage hook implemented in #186.
see nim-web3 how subscription works. closing.

@jangko jangko closed this as completed Jan 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants