-
Notifications
You must be signed in to change notification settings - Fork 352
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
Create a package:web_socket
WebSocket
from dart:io
WebSocket
#1173
Merged
brianquinlan
merged 4 commits into
dart-lang:master
from
brianquinlan:web_socket_constructor
Apr 4, 2024
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,8 @@ | ||
## 0.1.5 | ||
|
||
- Add the ability to create a `package:web_socket` `WebSocket` given a | ||
`dart:io` `WebSocket`. | ||
|
||
## 0.1.0 | ||
|
||
- Basic functionality in place. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
@TestOn('vm') | ||
library; | ||
|
||
import 'dart:io' as io; | ||
|
||
import 'package:test/test.dart'; | ||
import 'package:web_socket/io_web_socket.dart'; | ||
import 'package:web_socket/web_socket.dart'; | ||
|
||
void main() { | ||
group('fromWebSocket', () { | ||
late final io.HttpServer server; | ||
late io.HttpHeaders headers; | ||
late Uri uri; | ||
|
||
setUp(() async { | ||
server = (await io.HttpServer.bind('localhost', 0)) | ||
..listen((request) async { | ||
headers = request.headers; | ||
await io.WebSocketTransformer.upgrade(request) | ||
.then((webSocket) => webSocket.listen(webSocket.add)); | ||
}); | ||
uri = Uri.parse('ws://localhost:${server.port}'); | ||
}); | ||
|
||
test('custom headers', () async { | ||
final ws = IOWebSocket.fromWebSocket(await io.WebSocket.connect( | ||
uri.toString(), | ||
headers: {'fruit': 'apple'})); | ||
expect(headers['fruit'], ['apple']); | ||
ws.sendText('Hello World!'); | ||
expect(await ws.events.first, TextDataReceived('Hello World!')); | ||
await ws.close(); | ||
}); | ||
}); | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the version jump? Should this be
0.1.1
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I hadn't read the pre-1.0 semver convention:
Although semantic versioning doesn't promise any compatibility between versions prior to 1.0.0, the Dart community convention is to treat those versions semantically as well. The interpretation of each number is just shifted down one slot: going from 0.1.2 to 0.2.0 indicates a breaking change, going to 0.1.3 indicates a new feature, and going to 0.1.2+1 indicates a change that doesn't affect the public API. For simplicity's sake, avoid using + after the version reaches 1.0.0.