File tree Expand file tree Collapse file tree 2 files changed +7
-3
lines changed
web_socket_conformance_tests/lib/src Expand file tree Collapse file tree 2 files changed +7
-3
lines changed Original file line number Diff line number Diff line change 44
55import 'dart:async' ;
66import 'dart:convert' ;
7+ import 'dart:isolate' ;
78import 'dart:typed_data' ;
89
910import 'package:objective_c/objective_c.dart' as objc;
@@ -277,7 +278,7 @@ class CupertinoWebSocket implements WebSocket {
277278 print ('${DateTime .now ().millisecondsSinceEpoch / 1000.0 } '
278279 'cancelWithCloseCode($code , $reason ) '
279280 '${_task .state } ${_task .error }' );
280- _task. cancelWithCloseCode ( code, utf8.encode (reason).toNSData ());
281+ await _cancel (_task, code, utf8.encode (reason! ).toNSData ());
281282 await Future <void >.delayed (const Duration (seconds: 5 ));
282283 // Delay is 10 seconds!
283284 print ('${DateTime .now ().millisecondsSinceEpoch / 1000.0 } Task: $_task ' );
@@ -293,3 +294,7 @@ class CupertinoWebSocket implements WebSocket {
293294 @override
294295 String get protocol => _protocol;
295296}
297+
298+ Future <void > _cancel (
299+ URLSessionWebSocketTask task, int code, objc.NSData reason) =>
300+ Isolate .run (() => task.cancelWithCloseCode (code, reason));
Original file line number Diff line number Diff line change 22// for details. All rights reserved. Use of this source code is governed by a
33// BSD-style license that can be found in the LICENSE file.
44
5- import 'dart:isolate' ;
65import 'dart:typed_data' ;
76
87import 'package:async/async.dart' ;
@@ -136,7 +135,7 @@ void testCloseLocal(
136135 ..sendText ('Hello World' )
137136 ..sendText ('Hello World 2' )
138137 ..sendText ('Hello World 3' );
139- await Isolate . run (() => channel.close (3000 , 'Client initiated closure' ) );
138+ await channel.close (3000 , 'Client initiated closure' );
140139 final closeCode = await httpServerQueue.next as int ? ;
141140 final closeReason = await httpServerQueue.next as String ? ;
142141
You can’t perform that action at this time.
0 commit comments