-
Notifications
You must be signed in to change notification settings - Fork 362
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5214f76
commit caad9ca
Showing
4 changed files
with
50 additions
and
1 deletion.
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.1 | ||
|
||
- 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(); | ||
}); | ||
}); | ||
} |