OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 library web_socket_mojom; | 5 library web_socket_mojom; |
6 import 'dart:async'; | 6 import 'dart:async'; |
7 import 'package:mojo/bindings.dart' as bindings; | 7 import 'package:mojo/bindings.dart' as bindings; |
8 import 'package:mojo/core.dart' as core; | 8 import 'package:mojo/core.dart' as core; |
9 import 'package:mojo/mojo/bindings/types/service_describer.mojom.dart' as servic
e_describer; | 9 import 'package:mojo/mojo/bindings/types/service_describer.mojom.dart' as servic
e_describer; |
10 | 10 |
11 | 11 |
12 | 12 |
13 class _WebSocketConnectParams extends bindings.Struct { | 13 class _WebSocketConnectParams extends bindings.Struct { |
14 static const List<bindings.StructDataHeader> kVersions = const [ | 14 static const List<bindings.StructDataHeader> kVersions = const [ |
15 const bindings.StructDataHeader(48, 0) | 15 const bindings.StructDataHeader(48, 0) |
16 ]; | 16 ]; |
17 String url = null; | 17 String url = null; |
18 List<String> protocols = null; | 18 List<String> protocols = null; |
19 String origin = null; | 19 String origin = null; |
20 core.MojoDataPipeConsumer sendStream = null; | 20 core.MojoDataPipeConsumer sendStream = null; |
21 WebSocketClientInterface client = null; | 21 WebSocketClientInterface client = null; |
22 | 22 |
23 _WebSocketConnectParams() : super(kVersions.last.size); | 23 _WebSocketConnectParams() : super(kVersions.last.size); |
24 | 24 |
| 25 _WebSocketConnectParams.init( |
| 26 String this.url, |
| 27 List<String> this.protocols, |
| 28 String this.origin, |
| 29 core.MojoDataPipeConsumer this.sendStream, |
| 30 WebSocketClientInterface this.client |
| 31 ) : super(kVersions.last.size); |
| 32 |
25 static _WebSocketConnectParams deserialize(bindings.Message message) { | 33 static _WebSocketConnectParams deserialize(bindings.Message message) { |
26 var decoder = new bindings.Decoder(message); | 34 var decoder = new bindings.Decoder(message); |
27 var result = decode(decoder); | 35 var result = decode(decoder); |
28 if (decoder.excessHandles != null) { | 36 if (decoder.excessHandles != null) { |
29 decoder.excessHandles.forEach((h) => h.close()); | 37 decoder.excessHandles.forEach((h) => h.close()); |
30 } | 38 } |
31 return result; | 39 return result; |
32 } | 40 } |
33 | 41 |
34 static _WebSocketConnectParams decode(bindings.Decoder decoder0) { | 42 static _WebSocketConnectParams decode(bindings.Decoder decoder0) { |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 class _WebSocketSendParams extends bindings.Struct { | 159 class _WebSocketSendParams extends bindings.Struct { |
152 static const List<bindings.StructDataHeader> kVersions = const [ | 160 static const List<bindings.StructDataHeader> kVersions = const [ |
153 const bindings.StructDataHeader(24, 0) | 161 const bindings.StructDataHeader(24, 0) |
154 ]; | 162 ]; |
155 bool fin = false; | 163 bool fin = false; |
156 WebSocketMessageType type = null; | 164 WebSocketMessageType type = null; |
157 int numBytes = 0; | 165 int numBytes = 0; |
158 | 166 |
159 _WebSocketSendParams() : super(kVersions.last.size); | 167 _WebSocketSendParams() : super(kVersions.last.size); |
160 | 168 |
| 169 _WebSocketSendParams.init( |
| 170 bool this.fin, |
| 171 WebSocketMessageType this.type, |
| 172 int this.numBytes |
| 173 ) : super(kVersions.last.size); |
| 174 |
161 static _WebSocketSendParams deserialize(bindings.Message message) { | 175 static _WebSocketSendParams deserialize(bindings.Message message) { |
162 var decoder = new bindings.Decoder(message); | 176 var decoder = new bindings.Decoder(message); |
163 var result = decode(decoder); | 177 var result = decode(decoder); |
164 if (decoder.excessHandles != null) { | 178 if (decoder.excessHandles != null) { |
165 decoder.excessHandles.forEach((h) => h.close()); | 179 decoder.excessHandles.forEach((h) => h.close()); |
166 } | 180 } |
167 return result; | 181 return result; |
168 } | 182 } |
169 | 183 |
170 static _WebSocketSendParams decode(bindings.Decoder decoder0) { | 184 static _WebSocketSendParams decode(bindings.Decoder decoder0) { |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 | 267 |
254 | 268 |
255 class _WebSocketFlowControlParams extends bindings.Struct { | 269 class _WebSocketFlowControlParams extends bindings.Struct { |
256 static const List<bindings.StructDataHeader> kVersions = const [ | 270 static const List<bindings.StructDataHeader> kVersions = const [ |
257 const bindings.StructDataHeader(16, 0) | 271 const bindings.StructDataHeader(16, 0) |
258 ]; | 272 ]; |
259 int quota = 0; | 273 int quota = 0; |
260 | 274 |
261 _WebSocketFlowControlParams() : super(kVersions.last.size); | 275 _WebSocketFlowControlParams() : super(kVersions.last.size); |
262 | 276 |
| 277 _WebSocketFlowControlParams.init( |
| 278 int this.quota |
| 279 ) : super(kVersions.last.size); |
| 280 |
263 static _WebSocketFlowControlParams deserialize(bindings.Message message) { | 281 static _WebSocketFlowControlParams deserialize(bindings.Message message) { |
264 var decoder = new bindings.Decoder(message); | 282 var decoder = new bindings.Decoder(message); |
265 var result = decode(decoder); | 283 var result = decode(decoder); |
266 if (decoder.excessHandles != null) { | 284 if (decoder.excessHandles != null) { |
267 decoder.excessHandles.forEach((h) => h.close()); | 285 decoder.excessHandles.forEach((h) => h.close()); |
268 } | 286 } |
269 return result; | 287 return result; |
270 } | 288 } |
271 | 289 |
272 static _WebSocketFlowControlParams decode(bindings.Decoder decoder0) { | 290 static _WebSocketFlowControlParams decode(bindings.Decoder decoder0) { |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 | 344 |
327 class _WebSocketCloseParams extends bindings.Struct { | 345 class _WebSocketCloseParams extends bindings.Struct { |
328 static const List<bindings.StructDataHeader> kVersions = const [ | 346 static const List<bindings.StructDataHeader> kVersions = const [ |
329 const bindings.StructDataHeader(24, 0) | 347 const bindings.StructDataHeader(24, 0) |
330 ]; | 348 ]; |
331 int code = 0; | 349 int code = 0; |
332 String reason = null; | 350 String reason = null; |
333 | 351 |
334 _WebSocketCloseParams() : super(kVersions.last.size); | 352 _WebSocketCloseParams() : super(kVersions.last.size); |
335 | 353 |
| 354 _WebSocketCloseParams.init( |
| 355 int this.code, |
| 356 String this.reason |
| 357 ) : super(kVersions.last.size); |
| 358 |
336 static _WebSocketCloseParams deserialize(bindings.Message message) { | 359 static _WebSocketCloseParams deserialize(bindings.Message message) { |
337 var decoder = new bindings.Decoder(message); | 360 var decoder = new bindings.Decoder(message); |
338 var result = decode(decoder); | 361 var result = decode(decoder); |
339 if (decoder.excessHandles != null) { | 362 if (decoder.excessHandles != null) { |
340 decoder.excessHandles.forEach((h) => h.close()); | 363 decoder.excessHandles.forEach((h) => h.close()); |
341 } | 364 } |
342 return result; | 365 return result; |
343 } | 366 } |
344 | 367 |
345 static _WebSocketCloseParams decode(bindings.Decoder decoder0) { | 368 static _WebSocketCloseParams decode(bindings.Decoder decoder0) { |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
413 class _WebSocketClientDidConnectParams extends bindings.Struct { | 436 class _WebSocketClientDidConnectParams extends bindings.Struct { |
414 static const List<bindings.StructDataHeader> kVersions = const [ | 437 static const List<bindings.StructDataHeader> kVersions = const [ |
415 const bindings.StructDataHeader(32, 0) | 438 const bindings.StructDataHeader(32, 0) |
416 ]; | 439 ]; |
417 String selectedSubprotocol = null; | 440 String selectedSubprotocol = null; |
418 String extensions = null; | 441 String extensions = null; |
419 core.MojoDataPipeConsumer receiveStream = null; | 442 core.MojoDataPipeConsumer receiveStream = null; |
420 | 443 |
421 _WebSocketClientDidConnectParams() : super(kVersions.last.size); | 444 _WebSocketClientDidConnectParams() : super(kVersions.last.size); |
422 | 445 |
| 446 _WebSocketClientDidConnectParams.init( |
| 447 String this.selectedSubprotocol, |
| 448 String this.extensions, |
| 449 core.MojoDataPipeConsumer this.receiveStream |
| 450 ) : super(kVersions.last.size); |
| 451 |
423 static _WebSocketClientDidConnectParams deserialize(bindings.Message message)
{ | 452 static _WebSocketClientDidConnectParams deserialize(bindings.Message message)
{ |
424 var decoder = new bindings.Decoder(message); | 453 var decoder = new bindings.Decoder(message); |
425 var result = decode(decoder); | 454 var result = decode(decoder); |
426 if (decoder.excessHandles != null) { | 455 if (decoder.excessHandles != null) { |
427 decoder.excessHandles.forEach((h) => h.close()); | 456 decoder.excessHandles.forEach((h) => h.close()); |
428 } | 457 } |
429 return result; | 458 return result; |
430 } | 459 } |
431 | 460 |
432 static _WebSocketClientDidConnectParams decode(bindings.Decoder decoder0) { | 461 static _WebSocketClientDidConnectParams decode(bindings.Decoder decoder0) { |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
510 class _WebSocketClientDidReceiveDataParams extends bindings.Struct { | 539 class _WebSocketClientDidReceiveDataParams extends bindings.Struct { |
511 static const List<bindings.StructDataHeader> kVersions = const [ | 540 static const List<bindings.StructDataHeader> kVersions = const [ |
512 const bindings.StructDataHeader(24, 0) | 541 const bindings.StructDataHeader(24, 0) |
513 ]; | 542 ]; |
514 bool fin = false; | 543 bool fin = false; |
515 WebSocketMessageType type = null; | 544 WebSocketMessageType type = null; |
516 int numBytes = 0; | 545 int numBytes = 0; |
517 | 546 |
518 _WebSocketClientDidReceiveDataParams() : super(kVersions.last.size); | 547 _WebSocketClientDidReceiveDataParams() : super(kVersions.last.size); |
519 | 548 |
| 549 _WebSocketClientDidReceiveDataParams.init( |
| 550 bool this.fin, |
| 551 WebSocketMessageType this.type, |
| 552 int this.numBytes |
| 553 ) : super(kVersions.last.size); |
| 554 |
520 static _WebSocketClientDidReceiveDataParams deserialize(bindings.Message messa
ge) { | 555 static _WebSocketClientDidReceiveDataParams deserialize(bindings.Message messa
ge) { |
521 var decoder = new bindings.Decoder(message); | 556 var decoder = new bindings.Decoder(message); |
522 var result = decode(decoder); | 557 var result = decode(decoder); |
523 if (decoder.excessHandles != null) { | 558 if (decoder.excessHandles != null) { |
524 decoder.excessHandles.forEach((h) => h.close()); | 559 decoder.excessHandles.forEach((h) => h.close()); |
525 } | 560 } |
526 return result; | 561 return result; |
527 } | 562 } |
528 | 563 |
529 static _WebSocketClientDidReceiveDataParams decode(bindings.Decoder decoder0)
{ | 564 static _WebSocketClientDidReceiveDataParams decode(bindings.Decoder decoder0)
{ |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
612 | 647 |
613 | 648 |
614 class _WebSocketClientDidReceiveFlowControlParams extends bindings.Struct { | 649 class _WebSocketClientDidReceiveFlowControlParams extends bindings.Struct { |
615 static const List<bindings.StructDataHeader> kVersions = const [ | 650 static const List<bindings.StructDataHeader> kVersions = const [ |
616 const bindings.StructDataHeader(16, 0) | 651 const bindings.StructDataHeader(16, 0) |
617 ]; | 652 ]; |
618 int quota = 0; | 653 int quota = 0; |
619 | 654 |
620 _WebSocketClientDidReceiveFlowControlParams() : super(kVersions.last.size); | 655 _WebSocketClientDidReceiveFlowControlParams() : super(kVersions.last.size); |
621 | 656 |
| 657 _WebSocketClientDidReceiveFlowControlParams.init( |
| 658 int this.quota |
| 659 ) : super(kVersions.last.size); |
| 660 |
622 static _WebSocketClientDidReceiveFlowControlParams deserialize(bindings.Messag
e message) { | 661 static _WebSocketClientDidReceiveFlowControlParams deserialize(bindings.Messag
e message) { |
623 var decoder = new bindings.Decoder(message); | 662 var decoder = new bindings.Decoder(message); |
624 var result = decode(decoder); | 663 var result = decode(decoder); |
625 if (decoder.excessHandles != null) { | 664 if (decoder.excessHandles != null) { |
626 decoder.excessHandles.forEach((h) => h.close()); | 665 decoder.excessHandles.forEach((h) => h.close()); |
627 } | 666 } |
628 return result; | 667 return result; |
629 } | 668 } |
630 | 669 |
631 static _WebSocketClientDidReceiveFlowControlParams decode(bindings.Decoder dec
oder0) { | 670 static _WebSocketClientDidReceiveFlowControlParams decode(bindings.Decoder dec
oder0) { |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
684 | 723 |
685 | 724 |
686 class _WebSocketClientDidFailParams extends bindings.Struct { | 725 class _WebSocketClientDidFailParams extends bindings.Struct { |
687 static const List<bindings.StructDataHeader> kVersions = const [ | 726 static const List<bindings.StructDataHeader> kVersions = const [ |
688 const bindings.StructDataHeader(16, 0) | 727 const bindings.StructDataHeader(16, 0) |
689 ]; | 728 ]; |
690 String message = null; | 729 String message = null; |
691 | 730 |
692 _WebSocketClientDidFailParams() : super(kVersions.last.size); | 731 _WebSocketClientDidFailParams() : super(kVersions.last.size); |
693 | 732 |
| 733 _WebSocketClientDidFailParams.init( |
| 734 String this.message |
| 735 ) : super(kVersions.last.size); |
| 736 |
694 static _WebSocketClientDidFailParams deserialize(bindings.Message message) { | 737 static _WebSocketClientDidFailParams deserialize(bindings.Message message) { |
695 var decoder = new bindings.Decoder(message); | 738 var decoder = new bindings.Decoder(message); |
696 var result = decode(decoder); | 739 var result = decode(decoder); |
697 if (decoder.excessHandles != null) { | 740 if (decoder.excessHandles != null) { |
698 decoder.excessHandles.forEach((h) => h.close()); | 741 decoder.excessHandles.forEach((h) => h.close()); |
699 } | 742 } |
700 return result; | 743 return result; |
701 } | 744 } |
702 | 745 |
703 static _WebSocketClientDidFailParams decode(bindings.Decoder decoder0) { | 746 static _WebSocketClientDidFailParams decode(bindings.Decoder decoder0) { |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
758 class _WebSocketClientDidCloseParams extends bindings.Struct { | 801 class _WebSocketClientDidCloseParams extends bindings.Struct { |
759 static const List<bindings.StructDataHeader> kVersions = const [ | 802 static const List<bindings.StructDataHeader> kVersions = const [ |
760 const bindings.StructDataHeader(24, 0) | 803 const bindings.StructDataHeader(24, 0) |
761 ]; | 804 ]; |
762 bool wasClean = false; | 805 bool wasClean = false; |
763 int code = 0; | 806 int code = 0; |
764 String reason = null; | 807 String reason = null; |
765 | 808 |
766 _WebSocketClientDidCloseParams() : super(kVersions.last.size); | 809 _WebSocketClientDidCloseParams() : super(kVersions.last.size); |
767 | 810 |
| 811 _WebSocketClientDidCloseParams.init( |
| 812 bool this.wasClean, |
| 813 int this.code, |
| 814 String this.reason |
| 815 ) : super(kVersions.last.size); |
| 816 |
768 static _WebSocketClientDidCloseParams deserialize(bindings.Message message) { | 817 static _WebSocketClientDidCloseParams deserialize(bindings.Message message) { |
769 var decoder = new bindings.Decoder(message); | 818 var decoder = new bindings.Decoder(message); |
770 var result = decode(decoder); | 819 var result = decode(decoder); |
771 if (decoder.excessHandles != null) { | 820 if (decoder.excessHandles != null) { |
772 decoder.excessHandles.forEach((h) => h.close()); | 821 decoder.excessHandles.forEach((h) => h.close()); |
773 } | 822 } |
774 return result; | 823 return result; |
775 } | 824 } |
776 | 825 |
777 static _WebSocketClientDidCloseParams decode(bindings.Decoder decoder0) { | 826 static _WebSocketClientDidCloseParams decode(bindings.Decoder decoder0) { |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
912 return 'WebSocketMessageType.binary'; | 961 return 'WebSocketMessageType.binary'; |
913 default: | 962 default: |
914 return null; | 963 return null; |
915 } | 964 } |
916 } | 965 } |
917 | 966 |
918 int toJson() => mojoEnumValue; | 967 int toJson() => mojoEnumValue; |
919 } | 968 } |
920 | 969 |
921 class _WebSocketServiceDescription implements service_describer.ServiceDescripti
on { | 970 class _WebSocketServiceDescription implements service_describer.ServiceDescripti
on { |
922 dynamic getTopLevelInterface([Function responseFactory]) => | 971 void getTopLevelInterface(Function responder) { |
923 responseFactory(null); | 972 responder(null); |
| 973 } |
924 | 974 |
925 dynamic getTypeDefinition(String typeKey, [Function responseFactory]) => | 975 void getTypeDefinition(String typeKey, Function responder) { |
926 responseFactory(null); | 976 responder(null); |
| 977 } |
927 | 978 |
928 dynamic getAllTypeDefinitions([Function responseFactory]) => | 979 void getAllTypeDefinitions(Function responder) { |
929 responseFactory(null); | 980 responder(null); |
| 981 } |
930 } | 982 } |
931 | 983 |
932 abstract class WebSocket { | 984 abstract class WebSocket { |
933 static const String serviceName = null; | 985 static const String serviceName = null; |
934 | 986 |
935 static service_describer.ServiceDescription _cachedServiceDescription; | 987 static service_describer.ServiceDescription _cachedServiceDescription; |
936 static service_describer.ServiceDescription get serviceDescription { | 988 static service_describer.ServiceDescription get serviceDescription { |
937 if (_cachedServiceDescription == null) { | 989 if (_cachedServiceDescription == null) { |
938 _cachedServiceDescription = new _WebSocketServiceDescription(); | 990 _cachedServiceDescription = new _WebSocketServiceDescription(); |
939 } | 991 } |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1097 : super.fromHandle(handle, autoBegin: impl != null) { | 1149 : super.fromHandle(handle, autoBegin: impl != null) { |
1098 _impl = impl; | 1150 _impl = impl; |
1099 } | 1151 } |
1100 | 1152 |
1101 _WebSocketStubControl.unbound([this._impl]) : super.unbound(); | 1153 _WebSocketStubControl.unbound([this._impl]) : super.unbound(); |
1102 | 1154 |
1103 String get serviceName => WebSocket.serviceName; | 1155 String get serviceName => WebSocket.serviceName; |
1104 | 1156 |
1105 | 1157 |
1106 | 1158 |
1107 dynamic handleMessage(bindings.ServiceMessage message) { | 1159 void handleMessage(bindings.ServiceMessage message) { |
1108 if (bindings.ControlMessageHandler.isControlMessage(message)) { | 1160 if (bindings.ControlMessageHandler.isControlMessage(message)) { |
1109 return bindings.ControlMessageHandler.handleMessage(this, | 1161 bindings.ControlMessageHandler.handleMessage( |
1110 0, | 1162 this, 0, message); |
1111 message); | 1163 return; |
1112 } | 1164 } |
1113 if (_impl == null) { | 1165 if (_impl == null) { |
1114 throw new core.MojoApiError("$this has no implementation set"); | 1166 throw new core.MojoApiError("$this has no implementation set"); |
1115 } | 1167 } |
1116 switch (message.header.type) { | 1168 switch (message.header.type) { |
1117 case _webSocketMethodConnectName: | 1169 case _webSocketMethodConnectName: |
1118 var params = _WebSocketConnectParams.deserialize( | 1170 var params = _WebSocketConnectParams.deserialize( |
1119 message.payload); | 1171 message.payload); |
1120 _impl.connect(params.url, params.protocols, params.origin, params.sendSt
ream, params.client); | 1172 _impl.connect(params.url, params.protocols, params.origin, params.sendSt
ream, params.client); |
1121 break; | 1173 break; |
1122 case _webSocketMethodSendName: | 1174 case _webSocketMethodSendName: |
1123 var params = _WebSocketSendParams.deserialize( | 1175 var params = _WebSocketSendParams.deserialize( |
1124 message.payload); | 1176 message.payload); |
1125 _impl.send(params.fin, params.type, params.numBytes); | 1177 _impl.send(params.fin, params.type, params.numBytes); |
1126 break; | 1178 break; |
1127 case _webSocketMethodFlowControlName: | 1179 case _webSocketMethodFlowControlName: |
1128 var params = _WebSocketFlowControlParams.deserialize( | 1180 var params = _WebSocketFlowControlParams.deserialize( |
1129 message.payload); | 1181 message.payload); |
1130 _impl.flowControl(params.quota); | 1182 _impl.flowControl(params.quota); |
1131 break; | 1183 break; |
1132 case _webSocketMethodCloseName: | 1184 case _webSocketMethodCloseName: |
1133 var params = _WebSocketCloseParams.deserialize( | 1185 var params = _WebSocketCloseParams.deserialize( |
1134 message.payload); | 1186 message.payload); |
1135 _impl.close_(params.code, params.reason); | 1187 _impl.close_(params.code, params.reason); |
1136 break; | 1188 break; |
1137 default: | 1189 default: |
1138 throw new bindings.MojoCodecError("Unexpected message name"); | 1190 throw new bindings.MojoCodecError("Unexpected message name"); |
1139 break; | 1191 break; |
1140 } | 1192 } |
1141 return null; | |
1142 } | 1193 } |
1143 | 1194 |
1144 WebSocket get impl => _impl; | 1195 WebSocket get impl => _impl; |
1145 set impl(WebSocket d) { | 1196 set impl(WebSocket d) { |
1146 if (d == null) { | 1197 if (d == null) { |
1147 throw new core.MojoApiError("$this: Cannot set a null implementation"); | 1198 throw new core.MojoApiError("$this: Cannot set a null implementation"); |
1148 } | 1199 } |
1149 if (isBound && (_impl == null)) { | 1200 if (isBound && (_impl == null)) { |
1150 beginHandlingEvents(); | 1201 beginHandlingEvents(); |
1151 } | 1202 } |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1206 } | 1257 } |
1207 } | 1258 } |
1208 | 1259 |
1209 const int _webSocketClientMethodDidConnectName = 0; | 1260 const int _webSocketClientMethodDidConnectName = 0; |
1210 const int _webSocketClientMethodDidReceiveDataName = 1; | 1261 const int _webSocketClientMethodDidReceiveDataName = 1; |
1211 const int _webSocketClientMethodDidReceiveFlowControlName = 2; | 1262 const int _webSocketClientMethodDidReceiveFlowControlName = 2; |
1212 const int _webSocketClientMethodDidFailName = 3; | 1263 const int _webSocketClientMethodDidFailName = 3; |
1213 const int _webSocketClientMethodDidCloseName = 4; | 1264 const int _webSocketClientMethodDidCloseName = 4; |
1214 | 1265 |
1215 class _WebSocketClientServiceDescription implements service_describer.ServiceDes
cription { | 1266 class _WebSocketClientServiceDescription implements service_describer.ServiceDes
cription { |
1216 dynamic getTopLevelInterface([Function responseFactory]) => | 1267 void getTopLevelInterface(Function responder) { |
1217 responseFactory(null); | 1268 responder(null); |
| 1269 } |
1218 | 1270 |
1219 dynamic getTypeDefinition(String typeKey, [Function responseFactory]) => | 1271 void getTypeDefinition(String typeKey, Function responder) { |
1220 responseFactory(null); | 1272 responder(null); |
| 1273 } |
1221 | 1274 |
1222 dynamic getAllTypeDefinitions([Function responseFactory]) => | 1275 void getAllTypeDefinitions(Function responder) { |
1223 responseFactory(null); | 1276 responder(null); |
| 1277 } |
1224 } | 1278 } |
1225 | 1279 |
1226 abstract class WebSocketClient { | 1280 abstract class WebSocketClient { |
1227 static const String serviceName = null; | 1281 static const String serviceName = null; |
1228 | 1282 |
1229 static service_describer.ServiceDescription _cachedServiceDescription; | 1283 static service_describer.ServiceDescription _cachedServiceDescription; |
1230 static service_describer.ServiceDescription get serviceDescription { | 1284 static service_describer.ServiceDescription get serviceDescription { |
1231 if (_cachedServiceDescription == null) { | 1285 if (_cachedServiceDescription == null) { |
1232 _cachedServiceDescription = new _WebSocketClientServiceDescription(); | 1286 _cachedServiceDescription = new _WebSocketClientServiceDescription(); |
1233 } | 1287 } |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1400 : super.fromHandle(handle, autoBegin: impl != null) { | 1454 : super.fromHandle(handle, autoBegin: impl != null) { |
1401 _impl = impl; | 1455 _impl = impl; |
1402 } | 1456 } |
1403 | 1457 |
1404 _WebSocketClientStubControl.unbound([this._impl]) : super.unbound(); | 1458 _WebSocketClientStubControl.unbound([this._impl]) : super.unbound(); |
1405 | 1459 |
1406 String get serviceName => WebSocketClient.serviceName; | 1460 String get serviceName => WebSocketClient.serviceName; |
1407 | 1461 |
1408 | 1462 |
1409 | 1463 |
1410 dynamic handleMessage(bindings.ServiceMessage message) { | 1464 void handleMessage(bindings.ServiceMessage message) { |
1411 if (bindings.ControlMessageHandler.isControlMessage(message)) { | 1465 if (bindings.ControlMessageHandler.isControlMessage(message)) { |
1412 return bindings.ControlMessageHandler.handleMessage(this, | 1466 bindings.ControlMessageHandler.handleMessage( |
1413 0, | 1467 this, 0, message); |
1414 message); | 1468 return; |
1415 } | 1469 } |
1416 if (_impl == null) { | 1470 if (_impl == null) { |
1417 throw new core.MojoApiError("$this has no implementation set"); | 1471 throw new core.MojoApiError("$this has no implementation set"); |
1418 } | 1472 } |
1419 switch (message.header.type) { | 1473 switch (message.header.type) { |
1420 case _webSocketClientMethodDidConnectName: | 1474 case _webSocketClientMethodDidConnectName: |
1421 var params = _WebSocketClientDidConnectParams.deserialize( | 1475 var params = _WebSocketClientDidConnectParams.deserialize( |
1422 message.payload); | 1476 message.payload); |
1423 _impl.didConnect(params.selectedSubprotocol, params.extensions, params.r
eceiveStream); | 1477 _impl.didConnect(params.selectedSubprotocol, params.extensions, params.r
eceiveStream); |
1424 break; | 1478 break; |
(...skipping 14 matching lines...) Expand all Loading... |
1439 break; | 1493 break; |
1440 case _webSocketClientMethodDidCloseName: | 1494 case _webSocketClientMethodDidCloseName: |
1441 var params = _WebSocketClientDidCloseParams.deserialize( | 1495 var params = _WebSocketClientDidCloseParams.deserialize( |
1442 message.payload); | 1496 message.payload); |
1443 _impl.didClose(params.wasClean, params.code, params.reason); | 1497 _impl.didClose(params.wasClean, params.code, params.reason); |
1444 break; | 1498 break; |
1445 default: | 1499 default: |
1446 throw new bindings.MojoCodecError("Unexpected message name"); | 1500 throw new bindings.MojoCodecError("Unexpected message name"); |
1447 break; | 1501 break; |
1448 } | 1502 } |
1449 return null; | |
1450 } | 1503 } |
1451 | 1504 |
1452 WebSocketClient get impl => _impl; | 1505 WebSocketClient get impl => _impl; |
1453 set impl(WebSocketClient d) { | 1506 set impl(WebSocketClient d) { |
1454 if (d == null) { | 1507 if (d == null) { |
1455 throw new core.MojoApiError("$this: Cannot set a null implementation"); | 1508 throw new core.MojoApiError("$this: Cannot set a null implementation"); |
1456 } | 1509 } |
1457 if (isBound && (_impl == null)) { | 1510 if (isBound && (_impl == null)) { |
1458 beginHandlingEvents(); | 1511 beginHandlingEvents(); |
1459 } | 1512 } |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1512 void didFail(String message) { | 1565 void didFail(String message) { |
1513 return impl.didFail(message); | 1566 return impl.didFail(message); |
1514 } | 1567 } |
1515 void didClose(bool wasClean, int code, String reason) { | 1568 void didClose(bool wasClean, int code, String reason) { |
1516 return impl.didClose(wasClean, code, reason); | 1569 return impl.didClose(wasClean, code, reason); |
1517 } | 1570 } |
1518 } | 1571 } |
1519 | 1572 |
1520 | 1573 |
1521 | 1574 |
OLD | NEW |