Skip to content

Commit 4f3a093

Browse files
committed
Push
1 parent db1c5ab commit 4f3a093

File tree

2 files changed

+49
-1
lines changed

2 files changed

+49
-1
lines changed

pkgs/cupertino_http/lib/src/cupertino_api.dart

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ library;
2929
import 'dart:async';
3030
import 'dart:isolate';
3131

32+
import 'package:logging/logging.dart';
3233
import 'package:objective_c/objective_c.dart' as objc;
3334

3435
import 'native_cupertino_bindings.dart' as ncb;
@@ -54,6 +55,8 @@ export 'native_cupertino_bindings.dart'
5455
NSURLSessionWebSocketCloseCode,
5556
NSURLSessionWebSocketMessageType;
5657

58+
final _logger = Logger('ClassroomApp');
59+
5760
abstract class _ObjectHolder<T extends objc.NSObject> {
5861
final T _nsObject;
5962

@@ -850,6 +853,28 @@ class URLSession extends _ObjectHolder<ncb.NSURLSession> {
850853
}) {
851854
final protoBuilder = objc.ObjCProtocolBuilder();
852855

856+
final b =
857+
ncb.ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSError
858+
.blocking((_, nsSession, nsTask, nsError) {
859+
_logger.severe(
860+
'Complete: session: ${nsSession.ref.pointer} task: ${nsTask.ref.pointer}');
861+
_decrementTaskCount();
862+
if (onComplete != null) {
863+
onComplete(
864+
URLSession._(nsSession,
865+
isBackground: isBackground, hasDelegate: true),
866+
URLSessionTask._(nsTask),
867+
nsError);
868+
}
869+
});
870+
871+
final delegate = objc.getProtocol('NSURLSessionTaskDelegate');
872+
final sel = objc.registerName('URLSession:task:didCompleteWithError:');
873+
final signature = objc.getProtocolMethodSignature(delegate, sel,
874+
isRequired: false, isInstanceMethod: true)!;
875+
protoBuilder.implementMethod(sel, signature, b);
876+
877+
/*
853878
ncb.NSURLSessionDataDelegate.URLSession_task_didCompleteWithError_
854879
.implementAsListener(protoBuilder, (nsSession, nsTask, nsError) {
855880
_decrementTaskCount();
@@ -861,7 +886,7 @@ class URLSession extends _ObjectHolder<ncb.NSURLSession> {
861886
nsError);
862887
}
863888
});
864-
889+
*/
865890
if (onRedirect != null) {
866891
ncb
867892
.NSURLSessionDataDelegate
@@ -897,6 +922,9 @@ class URLSession extends _ObjectHolder<ncb.NSURLSession> {
897922
ncb.ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionDataTask_NSURLResponse_ffiVoidNSURLSessionResponseDisposition
898923
.blocking(
899924
(_, nsSession, nsDataTask, nsResponse, nsCompletionHandler) {
925+
_logger.severe(
926+
'Response: session: ${nsSession.ref.pointer} task: ${nsDataTask.ref.pointer}');
927+
900928
final exactResponse = URLResponse._exactURLResponseType(nsResponse);
901929
final disposition = onResponse(
902930
URLSession._(nsSession,
@@ -929,6 +957,24 @@ class URLSession extends _ObjectHolder<ncb.NSURLSession> {
929957
}
930958

931959
if (onData != null) {
960+
final b =
961+
ncb.ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionDataTask_NSData
962+
.blocking((_, nsSession, nsDataTask, nsData) {
963+
_logger.severe(
964+
'Data: session: ${nsSession.ref.pointer} task: ${nsDataTask.ref.pointer}');
965+
onData(
966+
URLSession._(nsSession,
967+
isBackground: isBackground, hasDelegate: true),
968+
URLSessionTask._(nsDataTask),
969+
nsData);
970+
});
971+
final delegate = objc.getProtocol('NSURLSessionDataDelegate');
972+
final sel = objc.registerName('URLSession:dataTask:didReceiveData:');
973+
final signature = objc.getProtocolMethodSignature(delegate, sel,
974+
isRequired: false, isInstanceMethod: true)!;
975+
protoBuilder.implementMethod(sel, signature, b);
976+
977+
/*
932978
ncb.NSURLSessionDataDelegate.URLSession_dataTask_didReceiveData_
933979
.implementAsListener(protoBuilder, (nsSession, nsDataTask, nsData) {
934980
onData(
@@ -937,6 +983,7 @@ class URLSession extends _ObjectHolder<ncb.NSURLSession> {
937983
URLSessionTask._(nsDataTask),
938984
nsData);
939985
});
986+
*/
940987
}
941988

942989
if (onFinishedDownloading != null) {

pkgs/cupertino_http/pubspec.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ dependencies:
1616
sdk: flutter
1717
http: ^1.2.0
1818
http_profile: ^0.1.0
19+
logging: ^1.3.0
1920
objective_c: ^4.0.0
2021
web_socket: ^0.1.0
2122

0 commit comments

Comments
 (0)