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

pass custom channel to websocket link #684

Closed
yap-studios opened this issue Jul 3, 2020 · 8 comments
Closed

pass custom channel to websocket link #684

yap-studios opened this issue Jul 3, 2020 · 8 comments

Comments

@yap-studios
Copy link

yap-studios commented Jul 3, 2020

Hi,

Is there a way to receive and handle ping/pong messages from a server?

Rgards

@micimize
Copy link
Collaborator

micimize commented Jul 3, 2020

what is a "ping/pong" message? If you mean subscription keep-alive messages, the websocket client should handle them for you

@yap-studios
Copy link
Author

yap-studios commented Jul 3, 2020

@micimize, when a server sends a websocket ping message I would like to receive the ping message and respond with a pong message.

I'm not interested in the keep-alive message since they are one-way.

@micimize
Copy link
Collaborator

micimize commented Jul 4, 2020

Hmm – well, that sounds like you'd like to access the underlying websocket for some non-graphql implementation detail. That seems like a fair ask to me, but unfortunately the websocket is currently private.

@micimize
Copy link
Collaborator

micimize commented Jul 4, 2020

If you use the v4 alpha, you can pass a channel to gql_websocket_link, which means you might be able to do what you want that way

@yap-studios
Copy link
Author

Would you consider making the websocket publicly accessible? Are there any drawbacks? I'm working on a production app and would like to stick to a stable version if possible.

@micimize
Copy link
Collaborator

micimize commented Jul 4, 2020

@yap-studios I think it should be, but it might be a minute before it gets done. In the meantime you can basically copy the websocket link and websocket client and make the vars public

@micimize micimize changed the title Receive and handle Ping/Pong messages pass custom channel to websocket link Aug 6, 2020
@micimize
Copy link
Collaborator

@micimize
Copy link
Collaborator

micimize commented Oct 7, 2020

I believe this is solved by the above in (#648),– please try with 4.0.0-beta.1 and comment if it is not satisfactory.

There is also even a way to override the connect function now:
https://github.com/zino-app/graphql-flutter/blob/d81011388be3787ea1221be7342b8c3fe25ffdd4/packages/graphql/lib/src/links/websocket_link/websocket_client.dart#L116

We can't really expose the raw socket as it is recreated on reconnects

@micimize micimize closed this as completed Oct 7, 2020
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

No branches or pull requests

2 participants