diff --git a/pkgs/cupertino_http/ffigen.yaml b/pkgs/cupertino_http/ffigen.yaml index af289ff8bd..2b664ec201 100644 --- a/pkgs/cupertino_http/ffigen.yaml +++ b/pkgs/cupertino_http/ffigen.yaml @@ -37,3 +37,7 @@ preamble: | comments: style: any length: full +enums: + as-int: + include: + - 'NSURLSessionWebSocketCloseCode' diff --git a/pkgs/cupertino_http/lib/cupertino_http.dart b/pkgs/cupertino_http/lib/cupertino_http.dart index 9bca9d9648..b85a868b4e 100644 --- a/pkgs/cupertino_http/lib/cupertino_http.dart +++ b/pkgs/cupertino_http/lib/cupertino_http.dart @@ -93,4 +93,4 @@ import 'src/cupertino_client.dart'; export 'src/cupertino_api.dart'; export 'src/cupertino_client.dart' show CupertinoClient; -// export 'src/cupertino_web_socket.dart'; +export 'src/cupertino_web_socket.dart'; diff --git a/pkgs/cupertino_http/lib/src/cupertino_api.dart b/pkgs/cupertino_http/lib/src/cupertino_api.dart index f072ce0d04..3b43e683d5 100644 --- a/pkgs/cupertino_http/lib/src/cupertino_api.dart +++ b/pkgs/cupertino_http/lib/src/cupertino_api.dart @@ -27,10 +27,8 @@ library; import 'dart:async'; -import 'dart:ffi'; import 'dart:isolate'; -import 'package:async/async.dart'; import 'package:objective_c/objective_c.dart' as objc; import 'native_cupertino_bindings.dart' as ncb; @@ -597,8 +595,7 @@ class URLSessionWebSocketTask extends URLSessionTask { /// The close code set when the WebSocket connection is closed. /// /// See [NSURLSessionWebSocketTask.closeCode](https://developer.apple.com/documentation/foundation/nsurlsessionwebsockettask/3181201-closecode) - ncb.NSURLSessionWebSocketCloseCode get closeCode => - _urlSessionWebSocketTask.closeCode; + int get closeCode => _urlSessionWebSocketTask.closeCode; /// The close reason set when the WebSocket connection is closed. /// If there is no close reason available this property will be null. @@ -613,28 +610,17 @@ class URLSessionWebSocketTask extends URLSessionTask { /// /// See [NSURLSessionWebSocketTask.sendMessage:completionHandler:](https://developer.apple.com/documentation/foundation/nsurlsessionwebsockettask/3181205-sendmessage) Future sendMessage(URLSessionWebSocketMessage message) async { - /* - _urlSessionWebSocketTask.sendMessage_completionHandler_( - message._nsObject, (error) error); - final completer = Completer(); - final completionPort = ReceivePort(); - completionPort.listen((message) { - final ep = Pointer.fromAddress(message as int); - if (ep.address == 0) { + _urlSessionWebSocketTask.sendMessage_completionHandler_(message._nsObject, + ncb.ObjCBlock_ffiVoid_NSError.listener((error) { + if (error == null) { completer.complete(); } else { - final error = - objc.NSError.castFromPointer(ep, retain: false, release: true); completer.completeError(error); } - completionPort.close(); - }); + })); - helperLibs.CUPHTTPSendMessage(_urlSessionWebSocketTask, message._nsObject, - completionPort.sendPort.nativePort); await completer.future; - */ } /// Receives a single WebSocket message. @@ -644,45 +630,25 @@ class URLSessionWebSocketTask extends URLSessionTask { /// See [NSURLSessionWebSocketTask.receiveMessageWithCompletionHandler:](https://developer.apple.com/documentation/foundation/nsurlsessionwebsockettask/3181204-receivemessagewithcompletionhand) Future receiveMessage() async { final completer = Completer(); - final completionPort = ReceivePort(); - completionPort.listen((d) { - final messageAndError = d as List; - - final mp = messageAndError[0] as int; - final ep = messageAndError[1] as int; - - final message = mp == 0 - ? null - : URLSessionWebSocketMessage._( - ncb.NSURLSessionWebSocketMessage.castFromPointer( - Pointer.fromAddress(mp).cast(), - retain: false, - release: true)); - final error = ep == 0 - ? null - : objc.NSError.castFromPointer( - Pointer.fromAddress(ep).cast(), - retain: false, - release: true); - + _urlSessionWebSocketTask.receiveMessageWithCompletionHandler_( + ncb.ObjCBlock_ffiVoid_NSURLSessionWebSocketMessage_NSError.listener( + (message, error) { if (error != null) { completer.completeError(error); + } else if (message != null) { + completer.complete(URLSessionWebSocketMessage._(message)); } else { - completer.complete(message!); + completer.completeError( + StateError('one of message or error must be non-null')); } - completionPort.close(); - }); - -// helperLibs.CUPHTTPReceiveMessage( -// _urlSessionWebSocketTask, completionPort.sendPort.nativePort); + })); return completer.future; } /// Sends close frame with the given code and optional reason. /// /// See [NSURLSessionWebSocketTask.cancelWithCloseCode:reason:](https://developer.apple.com/documentation/foundation/nsurlsessionwebsockettask/3181200-cancelwithclosecode) - void cancelWithCloseCode( - ncb.NSURLSessionWebSocketCloseCode closeCode, objc.NSData? reason) { + void cancelWithCloseCode(int closeCode, objc.NSData? reason) { _urlSessionWebSocketTask.cancelWithCloseCode_reason_(closeCode, reason); } @@ -868,7 +834,7 @@ class URLSession extends _ObjectHolder { URLSession session, URLSessionWebSocketTask task, String? protocol)? onWebSocketTaskOpened, void Function(URLSession session, URLSessionWebSocketTask task, - ncb.NSURLSessionWebSocketCloseCode closeCode, objc.NSData? reason)? + int closeCode, objc.NSData? reason)? onWebSocketTaskClosed, }) { final protoBuilder = objc.ObjCProtocolBuilder(); @@ -938,6 +904,21 @@ class URLSession extends _ObjectHolder { nsurlToUri(nsUrl)); } }); + + ncb.NSURLSessionWebSocketDelegate.addToBuilderAsListener(protoBuilder, + URLSession_webSocketTask_didOpenWithProtocol_: + (session, task, protocol) { + if (onWebSocketTaskOpened != null) { + onWebSocketTaskOpened(URLSession._(session, isBackground: isBackground), + URLSessionWebSocketTask._(task), protocol?.toString()); + } + }, URLSession_webSocketTask_didCloseWithCode_reason_: + (session, task, closeCode, reason) { + if (onWebSocketTaskClosed != null) { + onWebSocketTaskClosed(URLSession._(session, isBackground: isBackground), + URLSessionWebSocketTask._(task), closeCode, reason); + } + }); return protoBuilder.build(); } @@ -1011,7 +992,7 @@ class URLSession extends _ObjectHolder { URLSession session, URLSessionWebSocketTask task, String? protocol)? onWebSocketTaskOpened, void Function(URLSession session, URLSessionWebSocketTask task, - ncb.NSURLSessionWebSocketCloseCode? closeCode, objc.NSData? reason)? + int? closeCode, objc.NSData? reason)? onWebSocketTaskClosed, }) { // Avoid the complexity of simultaneous or out-of-order delegate callbacks @@ -1148,7 +1129,6 @@ class URLSession extends _ObjectHolder { throw UnsupportedError( 'WebSocket tasks are not supported in background sessions'); } - final URLSessionWebSocketTask task; if (protocols == null) { task = URLSessionWebSocketTask._( diff --git a/pkgs/cupertino_http/lib/src/cupertino_web_socket.dart b/pkgs/cupertino_http/lib/src/cupertino_web_socket.dart index dc4d748c14..d3bcafcd86 100644 --- a/pkgs/cupertino_http/lib/src/cupertino_web_socket.dart +++ b/pkgs/cupertino_http/lib/src/cupertino_web_socket.dart @@ -7,12 +7,13 @@ import 'dart:convert'; import 'dart:typed_data'; import 'package:web_socket/web_socket.dart'; +import 'package:objective_c/objective_c.dart' as objc; import 'cupertino_api.dart'; /// An error occurred while connecting to the peer. class ConnectionException extends WebSocketException { - final Error error; + final objc.NSError error; ConnectionException(super.message, this.error); @@ -115,7 +116,7 @@ class CupertinoWebSocket implements WebSocket { // 3. an error occurred (e.g. network failure) and `_connectionClosed` // will signal that and close `event`. webSocket._connectionClosed( - 1006, Data.fromList('abnormal close'.codeUnits)); + 1006, 'abnormal close'.codeUnits.toNSData()); } }); @@ -138,11 +139,13 @@ class CupertinoWebSocket implements WebSocket { late WebSocketEvent event; switch (value.type) { - case URLSessionWebSocketMessageType.urlSessionWebSocketMessageTypeString: + case NSURLSessionWebSocketMessageType + .NSURLSessionWebSocketMessageTypeString: event = TextDataReceived(value.string!); break; - case URLSessionWebSocketMessageType.urlSessionWebSocketMessageTypeData: - event = BinaryDataReceived(value.data!.bytes); + case NSURLSessionWebSocketMessageType + .NSURLSessionWebSocketMessageTypeData: + event = BinaryDataReceived(value.data!.toList()); break; } _events.add(event); @@ -158,28 +161,30 @@ class CupertinoWebSocket implements WebSocket { /// Close the WebSocket connection due to an error and send the /// [CloseReceived] event. void _closeConnectionWithError(Object e) { - if (e is Error) { - if (e.domain == 'NSPOSIXErrorDomain' && e.code == 57) { + if (e is objc.NSError) { + if (e.domain.toString() == 'NSPOSIXErrorDomain' && e.code == 57) { // Socket is not connected. // onWebSocketTaskClosed/onComplete will be invoked and may indicate a // close code. return; } - var (int code, String? reason) = switch ([e.domain, e.code]) { - ['NSPOSIXErrorDomain', 100] => (1002, e.localizedDescription), - _ => (1006, e.localizedDescription) + var (int code, String? reason) = switch ([e.domain.toString(), e.code]) { + ['NSPOSIXErrorDomain', 100] => ( + 1002, + e.localizedDescription.toString() + ), + _ => (1006, e.localizedDescription.toString()) }; _task.cancel(); - _connectionClosed( - code, reason == null ? null : Data.fromList(reason.codeUnits)); + _connectionClosed(code, reason.codeUnits.toNSData()); } else { throw StateError('unexpected error: $e'); } } - void _connectionClosed(int? closeCode, Data? reason) { + void _connectionClosed(int? closeCode, objc.NSData? reason) { if (!_events.isClosed) { - final closeReason = reason == null ? '' : utf8.decode(reason.bytes); + final closeReason = reason == null ? '' : utf8.decode(reason.toList()); _events ..add(CloseReceived(closeCode, closeReason)) @@ -193,7 +198,7 @@ class CupertinoWebSocket implements WebSocket { throw WebSocketConnectionClosed(); } _task - .sendMessage(URLSessionWebSocketMessage.fromData(Data.fromList(b))) + .sendMessage(URLSessionWebSocketMessage.fromData(b.toNSData())) .then((value) => value, onError: _closeConnectionWithError); } @@ -226,7 +231,7 @@ class CupertinoWebSocket implements WebSocket { unawaited(_events.close()); if (code != null) { reason = reason ?? ''; - _task.cancelWithCloseCode(code, Data.fromList(utf8.encode(reason))); + _task.cancelWithCloseCode(code, utf8.encode(reason).toNSData()); } else { _task.cancel(); } diff --git a/pkgs/cupertino_http/lib/src/native_cupertino_bindings.dart b/pkgs/cupertino_http/lib/src/native_cupertino_bindings.dart index c25f418f73..0d21df70ec 100644 --- a/pkgs/cupertino_http/lib/src/native_cupertino_bindings.dart +++ b/pkgs/cupertino_http/lib/src/native_cupertino_bindings.dart @@ -62375,9 +62375,9 @@ class NSURLSessionWebSocketTask extends NSURLSessionTask { /// Sends a close frame with the given closeCode. An optional reason can be provided while sending the close frame. /// Simply calling cancel on the task will result in a cancellation frame being sent without any reason. void cancelWithCloseCode_reason_( - NSURLSessionWebSocketCloseCode closeCode, objc.NSData? reason) { + DartNSInteger closeCode, objc.NSData? reason) { _objc_msgSend_18im7ej(this.ref.pointer, _sel_cancelWithCloseCode_reason_, - closeCode.value, reason?.ref.pointer ?? ffi.nullptr); + closeCode, reason?.ref.pointer ?? ffi.nullptr); } /// The maximum number of bytes to be buffered before erroring out. This includes the sum of all bytes from continuation frames. Receive calls will error out if this value is reached @@ -62392,9 +62392,8 @@ class NSURLSessionWebSocketTask extends NSURLSessionTask { } /// A task can be queried for it's close code at any point. When the task is not closed, it will be set to NSURLSessionWebSocketCloseCodeInvalid - NSURLSessionWebSocketCloseCode get closeCode { - final _ret = _objc_msgSend_a13zbl(this.ref.pointer, _sel_closeCode); - return NSURLSessionWebSocketCloseCode.fromValue(_ret); + DartNSInteger get closeCode { + return _objc_msgSend_a13zbl(this.ref.pointer, _sel_closeCode); } /// A task can be queried for it's close reason at any point. A nil value indicates no closeReason or that the task is still running @@ -62734,41 +62733,20 @@ late final _sel_sendPingWithPongReceiveHandler_ = objc.registerName("sendPingWithPongReceiveHandler:"); /// The WebSocket close codes follow the close codes given in the RFC -enum NSURLSessionWebSocketCloseCode { - NSURLSessionWebSocketCloseCodeInvalid(0), - NSURLSessionWebSocketCloseCodeNormalClosure(1000), - NSURLSessionWebSocketCloseCodeGoingAway(1001), - NSURLSessionWebSocketCloseCodeProtocolError(1002), - NSURLSessionWebSocketCloseCodeUnsupportedData(1003), - NSURLSessionWebSocketCloseCodeNoStatusReceived(1005), - NSURLSessionWebSocketCloseCodeAbnormalClosure(1006), - NSURLSessionWebSocketCloseCodeInvalidFramePayloadData(1007), - NSURLSessionWebSocketCloseCodePolicyViolation(1008), - NSURLSessionWebSocketCloseCodeMessageTooBig(1009), - NSURLSessionWebSocketCloseCodeMandatoryExtensionMissing(1010), - NSURLSessionWebSocketCloseCodeInternalServerError(1011), - NSURLSessionWebSocketCloseCodeTLSHandshakeFailure(1015); - - final int value; - const NSURLSessionWebSocketCloseCode(this.value); - - static NSURLSessionWebSocketCloseCode fromValue(int value) => switch (value) { - 0 => NSURLSessionWebSocketCloseCodeInvalid, - 1000 => NSURLSessionWebSocketCloseCodeNormalClosure, - 1001 => NSURLSessionWebSocketCloseCodeGoingAway, - 1002 => NSURLSessionWebSocketCloseCodeProtocolError, - 1003 => NSURLSessionWebSocketCloseCodeUnsupportedData, - 1005 => NSURLSessionWebSocketCloseCodeNoStatusReceived, - 1006 => NSURLSessionWebSocketCloseCodeAbnormalClosure, - 1007 => NSURLSessionWebSocketCloseCodeInvalidFramePayloadData, - 1008 => NSURLSessionWebSocketCloseCodePolicyViolation, - 1009 => NSURLSessionWebSocketCloseCodeMessageTooBig, - 1010 => NSURLSessionWebSocketCloseCodeMandatoryExtensionMissing, - 1011 => NSURLSessionWebSocketCloseCodeInternalServerError, - 1015 => NSURLSessionWebSocketCloseCodeTLSHandshakeFailure, - _ => throw ArgumentError( - "Unknown value for NSURLSessionWebSocketCloseCode: $value"), - }; +sealed class NSURLSessionWebSocketCloseCode { + static const NSURLSessionWebSocketCloseCodeInvalid = 0; + static const NSURLSessionWebSocketCloseCodeNormalClosure = 1000; + static const NSURLSessionWebSocketCloseCodeGoingAway = 1001; + static const NSURLSessionWebSocketCloseCodeProtocolError = 1002; + static const NSURLSessionWebSocketCloseCodeUnsupportedData = 1003; + static const NSURLSessionWebSocketCloseCodeNoStatusReceived = 1005; + static const NSURLSessionWebSocketCloseCodeAbnormalClosure = 1006; + static const NSURLSessionWebSocketCloseCodeInvalidFramePayloadData = 1007; + static const NSURLSessionWebSocketCloseCodePolicyViolation = 1008; + static const NSURLSessionWebSocketCloseCodeMessageTooBig = 1009; + static const NSURLSessionWebSocketCloseCodeMandatoryExtensionMissing = 1010; + static const NSURLSessionWebSocketCloseCodeInternalServerError = 1011; + static const NSURLSessionWebSocketCloseCodeTLSHandshakeFailure = 1015; } late final _sel_cancelWithCloseCode_reason_ = @@ -73262,8 +73240,7 @@ abstract final class NSURLSessionWebSocketDelegate { static objc.ObjCObjectBase implement( {void Function(NSURLSession, NSURLSessionWebSocketTask, objc.NSString?)? URLSession_webSocketTask_didOpenWithProtocol_, - void Function(NSURLSession, NSURLSessionWebSocketTask, - NSURLSessionWebSocketCloseCode, objc.NSData?)? + void Function(NSURLSession, NSURLSessionWebSocketTask, DartNSInteger, objc.NSData?)? URLSession_webSocketTask_didCloseWithCode_reason_, void Function(NSURLSession, NSURLSessionTask)? URLSession_didCreateTask_, void Function(NSURLSession, NSURLSessionTask, NSURLRequest, @@ -73280,7 +73257,9 @@ abstract final class NSURLSessionWebSocketDelegate { NSURLAuthenticationChallenge, objc.ObjCBlock)? URLSession_task_didReceiveChallenge_completionHandler_, - void Function(NSURLSession, NSURLSessionTask, objc.ObjCBlock)? URLSession_task_needNewBodyStream_, + void Function( + NSURLSession, NSURLSessionTask, objc.ObjCBlock)? + URLSession_task_needNewBodyStream_, void Function(NSURLSession, NSURLSessionTask, int, objc.ObjCBlock)? URLSession_task_needNewBodyStreamFromOffset_completionHandler_, void Function(NSURLSession, NSURLSessionTask, int, int, int)? URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, void Function(NSURLSession, NSURLSessionTask, NSHTTPURLResponse)? URLSession_task_didReceiveInformationalResponse_, @@ -73344,8 +73323,7 @@ abstract final class NSURLSessionWebSocketDelegate { static void addToBuilder(objc.ObjCProtocolBuilder builder, {void Function(NSURLSession, NSURLSessionWebSocketTask, objc.NSString?)? URLSession_webSocketTask_didOpenWithProtocol_, - void Function(NSURLSession, NSURLSessionWebSocketTask, - NSURLSessionWebSocketCloseCode, objc.NSData?)? + void Function(NSURLSession, NSURLSessionWebSocketTask, DartNSInteger, objc.NSData?)? URLSession_webSocketTask_didCloseWithCode_reason_, void Function(NSURLSession, NSURLSessionTask)? URLSession_didCreateTask_, void Function(NSURLSession, NSURLSessionTask, NSURLRequest, @@ -73362,7 +73340,9 @@ abstract final class NSURLSessionWebSocketDelegate { NSURLAuthenticationChallenge, objc.ObjCBlock)? URLSession_task_didReceiveChallenge_completionHandler_, - void Function(NSURLSession, NSURLSessionTask, objc.ObjCBlock)? URLSession_task_needNewBodyStream_, + void Function( + NSURLSession, NSURLSessionTask, objc.ObjCBlock)? + URLSession_task_needNewBodyStream_, void Function(NSURLSession, NSURLSessionTask, int, objc.ObjCBlock)? URLSession_task_needNewBodyStreamFromOffset_completionHandler_, void Function(NSURLSession, NSURLSessionTask, int, int, int)? URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, void Function(NSURLSession, NSURLSessionTask, NSHTTPURLResponse)? URLSession_task_didReceiveInformationalResponse_, @@ -73425,8 +73405,7 @@ abstract final class NSURLSessionWebSocketDelegate { static objc.ObjCObjectBase implementAsListener( {void Function(NSURLSession, NSURLSessionWebSocketTask, objc.NSString?)? URLSession_webSocketTask_didOpenWithProtocol_, - void Function(NSURLSession, NSURLSessionWebSocketTask, - NSURLSessionWebSocketCloseCode, objc.NSData?)? + void Function(NSURLSession, NSURLSessionWebSocketTask, DartNSInteger, objc.NSData?)? URLSession_webSocketTask_didCloseWithCode_reason_, void Function(NSURLSession, NSURLSessionTask)? URLSession_didCreateTask_, void Function(NSURLSession, NSURLSessionTask, NSURLRequest, @@ -73443,7 +73422,9 @@ abstract final class NSURLSessionWebSocketDelegate { NSURLAuthenticationChallenge, objc.ObjCBlock)? URLSession_task_didReceiveChallenge_completionHandler_, - void Function(NSURLSession, NSURLSessionTask, objc.ObjCBlock)? URLSession_task_needNewBodyStream_, + void Function( + NSURLSession, NSURLSessionTask, objc.ObjCBlock)? + URLSession_task_needNewBodyStream_, void Function(NSURLSession, NSURLSessionTask, int, objc.ObjCBlock)? URLSession_task_needNewBodyStreamFromOffset_completionHandler_, void Function(NSURLSession, NSURLSessionTask, int, int, int)? URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, void Function(NSURLSession, NSURLSessionTask, NSHTTPURLResponse)? URLSession_task_didReceiveInformationalResponse_, @@ -73514,8 +73495,7 @@ abstract final class NSURLSessionWebSocketDelegate { static void addToBuilderAsListener(objc.ObjCProtocolBuilder builder, {void Function(NSURLSession, NSURLSessionWebSocketTask, objc.NSString?)? URLSession_webSocketTask_didOpenWithProtocol_, - void Function(NSURLSession, NSURLSessionWebSocketTask, - NSURLSessionWebSocketCloseCode, objc.NSData?)? + void Function(NSURLSession, NSURLSessionWebSocketTask, DartNSInteger, objc.NSData?)? URLSession_webSocketTask_didCloseWithCode_reason_, void Function(NSURLSession, NSURLSessionTask)? URLSession_didCreateTask_, void Function(NSURLSession, NSURLSessionTask, NSURLRequest, @@ -73532,7 +73512,9 @@ abstract final class NSURLSessionWebSocketDelegate { NSURLAuthenticationChallenge, objc.ObjCBlock)? URLSession_task_didReceiveChallenge_completionHandler_, - void Function(NSURLSession, NSURLSessionTask, objc.ObjCBlock)? URLSession_task_needNewBodyStream_, + void Function( + NSURLSession, NSURLSessionTask, objc.ObjCBlock)? + URLSession_task_needNewBodyStream_, void Function(NSURLSession, NSURLSessionTask, int, objc.ObjCBlock)? URLSession_task_needNewBodyStreamFromOffset_completionHandler_, void Function(NSURLSession, NSURLSessionTask, int, int, int)? URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, void Function(NSURLSession, NSURLSessionTask, NSHTTPURLResponse)? URLSession_task_didReceiveInformationalResponse_, @@ -73627,8 +73609,8 @@ abstract final class NSURLSessionWebSocketDelegate { /// this information in the close frame static final URLSession_webSocketTask_didCloseWithCode_reason_ = objc.ObjCProtocolListenableMethod< - void Function(NSURLSession, NSURLSessionWebSocketTask, - NSURLSessionWebSocketCloseCode, objc.NSData?)>( + void Function(NSURLSession, NSURLSessionWebSocketTask, DartNSInteger, + objc.NSData?)>( _sel_URLSession_webSocketTask_didCloseWithCode_reason_, objc.getProtocolMethodSignature( _protocol_NSURLSessionWebSocketDelegate, @@ -73636,24 +73618,24 @@ abstract final class NSURLSessionWebSocketDelegate { isRequired: false, isInstanceMethod: true, ), - (void Function(NSURLSession, NSURLSessionWebSocketTask, - NSURLSessionWebSocketCloseCode, objc.NSData?) + (void Function(NSURLSession, NSURLSessionWebSocketTask, DartNSInteger, + objc.NSData?) func) => ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionWebSocketTask_NSURLSessionWebSocketCloseCode_NSData .fromFunction((ffi.Pointer _, NSURLSession arg1, NSURLSessionWebSocketTask arg2, - NSURLSessionWebSocketCloseCode arg3, + DartNSInteger arg3, objc.NSData? arg4) => func(arg1, arg2, arg3, arg4)), - (void Function(NSURLSession, NSURLSessionWebSocketTask, - NSURLSessionWebSocketCloseCode, objc.NSData?) + (void Function(NSURLSession, NSURLSessionWebSocketTask, DartNSInteger, + objc.NSData?) func) => ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionWebSocketTask_NSURLSessionWebSocketCloseCode_NSData .listener((ffi.Pointer _, NSURLSession arg1, NSURLSessionWebSocketTask arg2, - NSURLSessionWebSocketCloseCode arg3, + DartNSInteger arg3, objc.NSData? arg4) => func(arg1, arg2, arg3, arg4)), ); @@ -74475,7 +74457,7 @@ abstract final class ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionWebSocke /// This block must be invoked by native code running on the same thread as /// the isolate that registered it. Invoking the block on the wrong thread /// will result in a crash. - static objc.ObjCBlock, NSURLSession, NSURLSessionWebSocketTask, NSInteger, objc.NSData?)> fromFunction(void Function(ffi.Pointer, NSURLSession, NSURLSessionWebSocketTask, NSURLSessionWebSocketCloseCode, objc.NSData?) fn) => + static objc.ObjCBlock, NSURLSession, NSURLSessionWebSocketTask, NSInteger, objc.NSData?)> fromFunction(void Function(ffi.Pointer, NSURLSession, NSURLSessionWebSocketTask, DartNSInteger, objc.NSData?) fn) => objc.ObjCBlock, NSURLSession, NSURLSessionWebSocketTask, NSInteger, objc.NSData?)>( objc.newClosureBlock( _ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionWebSocketTask_NSURLSessionWebSocketCloseCode_NSData_closureCallable, @@ -74488,7 +74470,7 @@ abstract final class ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionWebSocke arg0, NSURLSession.castFromPointer(arg1, retain: true, release: true), NSURLSessionWebSocketTask.castFromPointer(arg2, retain: true, release: true), - NSURLSessionWebSocketCloseCode.fromValue(arg3), + arg3, arg4.address == 0 ? null : objc.NSData.castFromPointer(arg4, retain: true, release: true))), retain: false, release: true); @@ -74505,12 +74487,8 @@ abstract final class ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionWebSocke static objc.ObjCBlock< ffi.Void Function(ffi.Pointer, NSURLSession, NSURLSessionWebSocketTask, NSInteger, objc.NSData?)> listener( - void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionWebSocketTask, - NSURLSessionWebSocketCloseCode, - objc.NSData?) + void Function(ffi.Pointer, NSURLSession, + NSURLSessionWebSocketTask, DartNSInteger, objc.NSData?) fn) { final raw = objc.newClosureBlock( _ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionWebSocketTask_NSURLSessionWebSocketCloseCode_NSData_listenerCallable @@ -74527,7 +74505,7 @@ abstract final class ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionWebSocke retain: false, release: true), NSURLSessionWebSocketTask.castFromPointer(arg2, retain: false, release: true), - NSURLSessionWebSocketCloseCode.fromValue(arg3), + arg3, arg4.address == 0 ? null : objc.NSData.castFromPointer(arg4, @@ -74553,7 +74531,7 @@ extension ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionWebSocketTask_NSURL ffi.Pointer arg0, NSURLSession arg1, NSURLSessionWebSocketTask arg2, - NSURLSessionWebSocketCloseCode arg3, + DartNSInteger arg3, objc.NSData? arg4) => ref.pointer.ref.invoke .cast< @@ -74577,7 +74555,7 @@ extension ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionWebSocketTask_NSURL arg0, arg1.ref.pointer, arg2.ref.pointer, - arg3.value, + arg3, arg4?.ref.pointer ?? ffi.nullptr); }