blob: d0480c34b931b6c72b5c7e079ac130d18d535fc2 [file] [log] [blame]
// Copyright (c) 2017, 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.
// @dart = 2.9
/// @assertion int closeCode
/// The close code set when the WebSocket connection is closed. If there is no
/// close code available this property will be null.
/// @description Checks that the [closeCode] is null when connection is not
/// closed and is set to int value if the WebSocket connection is closed.
/// @author ngl@unipro.ru
import "dart:io";
import "../../../Utils/expect.dart";
main() {
HttpServer.bind("127.0.0.1", 0).then((server) {
server.listen((request) {
WebSocketTransformer
.upgrade(request)
.then((websocket) {
websocket.close();
});
});
var webs = WebSocket.connect("ws://127.0.0.1:${server.port}/");
webs.then((client) {
Expect.isTrue(client.closeCode == null);
client.close().then((_) {
Expect.isTrue(client.closeCode is int);
});
server.close();
});
});
}