Calogero
01/09/2023, 1:48 PMRustam Siniukov
01/09/2023, 1:59 PMKtorNSURLSessionDelegate
is a sealed class?
You should create custom NsUrlSessionDelegate
and call both Datadog and Ktor delegates from it. You can see in the API docs which methods are required to call.Calogero
01/09/2023, 3:45 PMRustam Siniukov
01/09/2023, 3:48 PMKtorNSURLSessionDelegate
to create an instance of itCalogero
01/09/2023, 3:58 PMCalogero
01/09/2023, 4:15 PMclass CustomDelegate(private val datadogDelegate: NSURLSessionDelegateProtocol, private val ktorDelegate: KtorNSURLSessionDelegate): NSObject(), NSURLSessionDelegateProtocol {
override fun URLSession(session: NSURLSession, didBecomeInvalidWithError: NSError?) {
datadogDelegate.URLSession(session, didBecomeInvalidWithError)
ktorDelegate.URLSession(session, didBecomeInvalidWithError)
}
}
fun test(datadogDelegate: NSURLSessionDelegateProtocol) {
val client = HttpClient(Darwin) {
engine {
val ktorDelegate = KtorNSURLSessionDelegate()
val session = NSURLSession.sessionWithConfiguration(NSURLSessionConfiguration.defaultSessionConfiguration, CustomDelegate(datadogDelegate, ktorDelegate), null)
usePreconfiguredSession(session, ktorDelegate)
}
}
}
Rustam Siniukov
01/09/2023, 4:29 PM* For HTTP requests to work property, it's important that users call these functions:
* * URLSession:dataTask:didReceiveData:
* * URLSession:task:didCompleteWithError:
* * URLSession:task:willPerformHTTPRedirection:newRequest:completionHandler:
*
* For WebSockets to work, it's important that users call these functions:
* * URLSession:webSocketTask:didOpenWithProtocol:
* * URLSession:webSocketTask:didCloseWithCode:reason:
Calogero
01/09/2023, 4:43 PMRustam Siniukov
01/09/2023, 4:46 PMCalogero
01/09/2023, 4:52 PMCarlos Monzon
11/02/2023, 12:56 PMCalogero
11/05/2023, 9:46 PMCarlos Monzon
11/06/2023, 3:31 AMCalogero
11/16/2023, 10:27 AMCarlos Monzon
11/16/2023, 1:43 PMCalogero
11/16/2023, 2:08 PMCalogero
11/16/2023, 2:28 PM