1 | | | import 'dart:async'; |
2 | | |
|
3 | | | import 'package:logger/web.dart'; |
4 | | | import 'package:meta/meta.dart'; |
5 | | |
|
6 | | | import '../../channel.dart'; |
7 | | | import '../../exceptions/exception_manager.dart'; |
8 | | | import '../../exceptions/squadron_error.dart'; |
9 | | | import '../../tokens/_squadron_cancelation_token.dart'; |
10 | | | import '../../typedefs.dart'; |
11 | | |
|
12 | | | @internal |
13 | | | final class DisconnectedChannel implements Channel { |
14 | | 11 | DisconnectedChannel([ExceptionManager? exceptionManager, this.logger]) |
15 | | 0 | : exceptionManager = exceptionManager ?? ExceptionManager(); |
16 | | |
|
17 | | | @override |
18 | | | final ExceptionManager exceptionManager; |
19 | | |
|
20 | | | @override |
21 | | | final Logger? logger; |
22 | | |
|
23 | | 0 | Never _disconnectedError() => |
24 | | 10 | throw SquadronErrorExt.create('Channel is not connected'); |
25 | | |
|
26 | | 0 | @override |
27 | | 0 | FutureOr<void> cancelStream(int streamId) => _disconnectedError(); |
28 | | |
|
29 | | 0 | @override |
30 | | 0 | FutureOr<void> cancelToken(SquadronCancelationToken? token) => |
31 | | 0 | _disconnectedError(); |
32 | | |
|
33 | | 0 | @override |
34 | | 0 | FutureOr<void> close() => _disconnectedError(); |
35 | | |
|
36 | | 0 | @override |
37 | | 0 | Future<dynamic> sendRequest( |
38 | | | int command, |
39 | | | List args, { |
40 | | | SquadronCancelationToken? token, |
41 | | | bool inspectRequest = false, |
42 | | | bool inspectResponse = false, |
43 | | | }) => |
44 | | 0 | _disconnectedError(); |
45 | | |
|
46 | | 0 | @override |
47 | | 0 | Stream<dynamic> sendStreamingRequest( |
48 | | | int command, |
49 | | | List args, { |
50 | | | SquadronCancelationToken? token, |
51 | | | bool inspectRequest = false, |
52 | | | bool inspectResponse = false, |
53 | | | }) => |
54 | | 0 | _disconnectedError(); |
55 | | |
|
56 | | 0 | @override |
57 | | 0 | PlatformChannel serialize() => _disconnectedError(); |
58 | | |
|
59 | | 0 | @override |
60 | | 0 | Channel share() => _disconnectedError(); |
61 | | | } |