Skip to content
This repository was archived by the owner on Feb 24, 2025. It is now read-only.

Added IOWebSocketChannel.ready field and timeout parameter - #85

Closed
KammererTob wants to merge 9 commits into
dart-archive:masterfrom
KammererTob:master
Closed

Added IOWebSocketChannel.ready field and timeout parameter#85
KammererTob wants to merge 9 commits into
dart-archive:masterfrom
KammererTob:master

Conversation

@KammererTob

Copy link
Copy Markdown

This pull request is a response to a comment in here: #60
I opened this new one since i don't have write access for the original pull request.

It contains the addition of a ready Future in the IOWebSochetChannel class, which completes when the underlying WebSocket connection is established. For the constructor which takes a WebSocket as input this Completer will instantly complete since it is assumed that the WebSocket is already connected.

It also contains a new timeout parameter which controls the timeout duration for the WebSocket future.

I also added tests, readme and changelog entries for both new additions. If you need anything else done please let me know.

@googlebot

Copy link
Copy Markdown

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

@KammererTob

Copy link
Copy Markdown
Author

@googlebot I signed it!

@googlebot

Copy link
Copy Markdown

All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter.

We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only @googlebot I consent. in this pull request.

Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the cla label to yes (if enabled on your project).

ℹ️ Googlers: Go here for more info.

@artur-ios-dev

Copy link
Copy Markdown

@googlebot I consent.

@googlebot

Copy link
Copy Markdown

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google.
In order to pass this check, please resolve this problem and then comment @googlebot I fixed it.. If the bot doesn't comment, it means it doesn't think anything has changed.

ℹ️ Googlers: Go here for more info.

@artur-ios-dev

artur-ios-dev commented Oct 20, 2019

Copy link
Copy Markdown

@KammererTob I have consented although I think you need to make sure the email address which you used for a commit is added to your account here: https://github.com/settings/emails since it does not recognize those commits as yours at the moment.

@KammererTob

Copy link
Copy Markdown
Author

@googlebot I fixed it.

@googlebot

Copy link
Copy Markdown

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

@KammererTob

Copy link
Copy Markdown
Author

@artrmz Thanks for the hint!

@artur-ios-dev

Copy link
Copy Markdown

Hi @natebosch and @jacob314, do you mind taking a look at this PR? Thanks!

@wanjm

wanjm commented Jun 8, 2020

Copy link
Copy Markdown

when will it be released?

@KammererTob

Copy link
Copy Markdown
Author

As written in the closed PR:

Not sure if helpful for anyone else, but since this PR was open for a long time and i needed to publish my package i used this:

Future<WebSocketChannel> connect(StompConfig config) async {
  var websocket =
      WebSocket.connect(config.url, headers: config.webSocketConnectHeaders);
  if (config.connectionTimeout != null) {
    websocket = websocket.timeout(config.connectionTimeout);
  }
  final webSocket = await websocket;
  return IOWebSocketChannel(webSocket);
}

It uses a timeout on the connect Future and the returned Future will resolve as soon as the connection is established.

@wanjm

wanjm commented Jun 8, 2020

Copy link
Copy Markdown

@KammererTob thanks.
I hope it can be released. as it is ready 25 days ago;

@wanjm

wanjm commented Jun 9, 2020

Copy link
Copy Markdown

this fix is only for ioWebsocket but not for WebSocketChannel , what a pity;

could any one tell me how to get the first message from the stream ; after the first message comes, I can make sure the connection is connected; then I can await for the others;

@KammererTob

Copy link
Copy Markdown
Author

You can use a platform specific api import and then define two different functions:

import 'src/_connect_api.dart'
    if (dart.library.html) 'src/_connect_html.dart'
    if (dart.library.io) 'src/_connect_io.dart' as platform;

_connect_api.dart:

Future<WebSocketChannel> connect(StompConfig config) {
  throw UnsupportedError('No implementation of the connect api provided');
}

_connect_html.dart:

Future<WebSocketChannel> connect(StompConfig config) async {
  var websocket = WebSocket(config.url);
  Future onOpenEvent = websocket.onOpen.first;
  if (config.connectionTimeout != null) {
    onOpenEvent = onOpenEvent.timeout(config.connectionTimeout);
  }
  await onOpenEvent;
  return HtmlWebSocketChannel(websocket);
}

_connect_io.dart:

Future<WebSocketChannel> connect(StompConfig config) async {
  var websocket =
      WebSocket.connect(config.url, headers: config.webSocketConnectHeaders);
  if (config.connectionTimeout != null) {
    websocket = websocket.timeout(config.connectionTimeout);
  }
  final webSocket = await websocket;
  return IOWebSocketChannel(webSocket);
}

@travishaagen

Copy link
Copy Markdown

Someone going to fix the merge conflicts?

@Jaribeau

Copy link
Copy Markdown

@KammererTob would you by chance be up for resolving these conflicts? I've got a few PRs in other repos depending on this change and would love to get them merged 👍

@KammererTob

Copy link
Copy Markdown
Author

Fixed merge conflicts.

@xsahil03x

Copy link
Copy Markdown

Any update on this PR?

@crossle

crossle commented May 20, 2021

Copy link
Copy Markdown

Any update?

@brianquinlan

Copy link
Copy Markdown
Contributor

Any update?

The ready field has already been updated and I'm not sure if there is a lot of value in the timeout property - it would be easy enough for the developer to add it themselves.

Should we close this?

@KammererTob

Copy link
Copy Markdown
Author

@brianquinlan I closed the PR since as you said it is no longer needed/superseded.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Development

Successfully merging this pull request may close these issues.

10 participants