Skip to content

Commit 816e120

Browse files
authored
Rename WebSocketAdapterWebSocketChannel to AdapterWebSocketChannel (dart-archive/web_socket_channel#344)
1 parent c0ea76f commit 816e120

File tree

4 files changed

+26
-25
lines changed

4 files changed

+26
-25
lines changed

pkgs/web_socket_channel/lib/web_socket_adapter_web_socket_channel.dart renamed to pkgs/web_socket_channel/lib/adapter_web_socket_channel.dart

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import 'src/channel.dart';
1313
import 'src/exception.dart';
1414

1515
/// A [WebSocketChannel] implemented using [WebSocket].
16-
class WebSocketAdapterWebSocketChannel extends StreamChannelMixin
16+
class AdapterWebSocketChannel extends StreamChannelMixin
1717
implements WebSocketChannel {
1818
@override
1919
String? get protocol => _protocol;
@@ -60,18 +60,17 @@ class WebSocketAdapterWebSocketChannel extends StreamChannelMixin
6060
/// the peer is able to select. See
6161
/// [RFC-6455 1.9](https://datatracker.ietf.org/doc/html/rfc6455#section-1.9).
6262
///
63-
/// After construction, the [WebSocketAdapterWebSocketChannel] may not be
63+
/// After construction, the [AdapterWebSocketChannel] may not be
6464
/// connected to the peer. The [ready] future will complete after the channel
6565
/// is connected. If there are errors creating the connection the [ready]
6666
/// future will complete with an error.
67-
factory WebSocketAdapterWebSocketChannel.connect(Uri url,
67+
factory AdapterWebSocketChannel.connect(Uri url,
6868
{Iterable<String>? protocols}) =>
69-
WebSocketAdapterWebSocketChannel(
70-
WebSocket.connect(url, protocols: protocols));
69+
AdapterWebSocketChannel(WebSocket.connect(url, protocols: protocols));
7170

7271
// Construct a [WebSocketWebSocketChannelAdapter] from an existing
7372
// [WebSocket].
74-
WebSocketAdapterWebSocketChannel(FutureOr<WebSocket> webSocket) {
73+
AdapterWebSocketChannel(FutureOr<WebSocket> webSocket) {
7574
Future<WebSocket> webSocketFuture;
7675
if (webSocket is WebSocket) {
7776
webSocketFuture = Future.value(webSocket);
@@ -135,9 +134,9 @@ class WebSocketAdapterWebSocketChannel extends StreamChannelMixin
135134
/// A [WebSocketSink] that tracks the close code and reason passed to [close].
136135
class _WebSocketSink extends DelegatingStreamSink implements WebSocketSink {
137136
/// The channel to which this sink belongs.
138-
final WebSocketAdapterWebSocketChannel _channel;
137+
final AdapterWebSocketChannel _channel;
139138

140-
_WebSocketSink(WebSocketAdapterWebSocketChannel channel)
139+
_WebSocketSink(AdapterWebSocketChannel channel)
141140
: _channel = channel,
142141
super(channel._controller.foreign.sink);
143142

pkgs/web_socket_channel/lib/io.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@
44

55
import 'dart:async';
66
import 'dart:io' show HttpClient, WebSocket;
7+
78
import 'package:web_socket/io_web_socket.dart' as io_web_socket;
89

10+
import 'adapter_web_socket_channel.dart';
911
import 'src/channel.dart';
1012
import 'src/exception.dart';
11-
import 'web_socket_adapter_web_socket_channel.dart';
1213

1314
/// A [WebSocketChannel] that communicates using a `dart:io` [WebSocket].
14-
class IOWebSocketChannel extends WebSocketAdapterWebSocketChannel {
15+
class IOWebSocketChannel extends AdapterWebSocketChannel {
1516
/// Creates a new WebSocket connection.
1617
///
1718
/// Connects to [url] using [WebSocket.connect] and returns a channel that can

pkgs/web_socket_channel/lib/src/channel.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import 'package:async/async.dart';
99
import 'package:crypto/crypto.dart';
1010
import 'package:stream_channel/stream_channel.dart';
1111

12-
import '../web_socket_adapter_web_socket_channel.dart';
12+
import '../adapter_web_socket_channel.dart';
1313
import 'exception.dart';
1414

1515
const String _webSocketGUID = '258EAFA5-E914-47DA-95CA-C5AB0DC85B11';
@@ -105,7 +105,7 @@ abstract interface class WebSocketChannel extends StreamChannelMixin {
105105
/// If there are errors creating the connection the [ready] future will
106106
/// complete with an error.
107107
static WebSocketChannel connect(Uri uri, {Iterable<String>? protocols}) =>
108-
WebSocketAdapterWebSocketChannel.connect(uri, protocols: protocols);
108+
AdapterWebSocketChannel.connect(uri, protocols: protocols);
109109
}
110110

111111
/// The sink exposed by a [WebSocketChannel].

pkgs/web_socket_channel/test/web_socket_adapter_web_socket_test.dart renamed to pkgs/web_socket_channel/test/adapter_web_socket_channel_test.dart

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,15 @@ import 'package:async/async.dart';
88
import 'package:stream_channel/stream_channel.dart';
99
import 'package:test/test.dart';
1010
import 'package:web_socket/web_socket.dart';
11+
import 'package:web_socket_channel/adapter_web_socket_channel.dart';
1112
import 'package:web_socket_channel/src/exception.dart';
12-
import 'package:web_socket_channel/web_socket_adapter_web_socket_channel.dart';
1313
import 'package:web_socket_channel/web_socket_channel.dart';
14+
1415
import 'echo_server_vm.dart'
1516
if (dart.library.js_interop) 'echo_server_web.dart';
1617

1718
void main() {
18-
group('WebSocketWebSocketChannelAdapter', () {
19+
group('AdapterWebSocketChannel', () {
1920
late Uri uri;
2021
late StreamChannel<Object?> httpServerChannel;
2122
late StreamQueue<Object?> httpServerQueue;
@@ -34,52 +35,52 @@ void main() {
3435

3536
test('failed connect', () async {
3637
final channel =
37-
WebSocketAdapterWebSocketChannel.connect(Uri.parse('ws://notahost'));
38+
AdapterWebSocketChannel.connect(Uri.parse('ws://notahost'));
3839

3940
await expectLater(
4041
channel.ready, throwsA(isA<WebSocketChannelException>()));
4142
});
4243

4344
test('good connect', () async {
44-
final channel = WebSocketAdapterWebSocketChannel.connect(uri);
45+
final channel = AdapterWebSocketChannel.connect(uri);
4546
await expectLater(channel.ready, completes);
4647
await channel.sink.close();
4748
});
4849

4950
test('echo empty text', () async {
50-
final channel = WebSocketAdapterWebSocketChannel.connect(uri);
51+
final channel = AdapterWebSocketChannel.connect(uri);
5152
await expectLater(channel.ready, completes);
5253
channel.sink.add('');
5354
expect(await channel.stream.first, '');
5455
await channel.sink.close();
5556
});
5657

5758
test('echo empty binary', () async {
58-
final channel = WebSocketAdapterWebSocketChannel.connect(uri);
59+
final channel = AdapterWebSocketChannel.connect(uri);
5960
await expectLater(channel.ready, completes);
6061
channel.sink.add(Uint8List.fromList(<int>[]));
6162
expect(await channel.stream.first, isEmpty);
6263
await channel.sink.close();
6364
});
6465

6566
test('echo hello', () async {
66-
final channel = WebSocketAdapterWebSocketChannel.connect(uri);
67+
final channel = AdapterWebSocketChannel.connect(uri);
6768
await expectLater(channel.ready, completes);
6869
channel.sink.add('hello');
6970
expect(await channel.stream.first, 'hello');
7071
await channel.sink.close();
7172
});
7273

7374
test('echo [1,2,3]', () async {
74-
final channel = WebSocketAdapterWebSocketChannel.connect(uri);
75+
final channel = AdapterWebSocketChannel.connect(uri);
7576
await expectLater(channel.ready, completes);
7677
channel.sink.add([1, 2, 3]);
7778
expect(await channel.stream.first, [1, 2, 3]);
7879
await channel.sink.close();
7980
});
8081

8182
test('alternative string and binary request and response', () async {
82-
final channel = WebSocketAdapterWebSocketChannel.connect(uri);
83+
final channel = AdapterWebSocketChannel.connect(uri);
8384
await expectLater(channel.ready, completes);
8485
channel.sink.add('This count says:');
8586
channel.sink.add([1, 2, 3]);
@@ -94,7 +95,7 @@ void main() {
9495
});
9596

9697
test('remote close', () async {
97-
final channel = WebSocketAdapterWebSocketChannel.connect(uri);
98+
final channel = AdapterWebSocketChannel.connect(uri);
9899
await expectLater(channel.ready, completes);
99100
channel.sink.add('close'); // Asks the peer to close.
100101
// Give the server time to send a close frame.
@@ -105,7 +106,7 @@ void main() {
105106
});
106107

107108
test('local close', () async {
108-
final channel = WebSocketAdapterWebSocketChannel.connect(uri);
109+
final channel = AdapterWebSocketChannel.connect(uri);
109110
await expectLater(channel.ready, completes);
110111
await channel.sink.close(3005, 'please close');
111112
expect(channel.closeCode, null);
@@ -114,7 +115,7 @@ void main() {
114115

115116
test('constructor with WebSocket', () async {
116117
final webSocket = await WebSocket.connect(uri);
117-
final channel = WebSocketAdapterWebSocketChannel(webSocket);
118+
final channel = AdapterWebSocketChannel(webSocket);
118119

119120
await expectLater(channel.ready, completes);
120121
channel.sink.add('This count says:');
@@ -131,7 +132,7 @@ void main() {
131132

132133
test('constructor with Future<WebSocket>', () async {
133134
final webSocketFuture = WebSocket.connect(uri);
134-
final channel = WebSocketAdapterWebSocketChannel(webSocketFuture);
135+
final channel = AdapterWebSocketChannel(webSocketFuture);
135136

136137
await expectLater(channel.ready, completes);
137138
channel.sink.add('This count says:');

0 commit comments

Comments
 (0)