hi, want to join ktor ios websockets development, ...
# ktor
r
hi, want to join ktor ios websockets development, how I can do it?
c
Hi. Thanks for interesting in contributing to ktor. Do you already have ideas how to implement it? It's actually not that far from making CIO work on native. But there are always "but"
The first and most serious problems I remember right now are: - mutability/sharing issues because a client should always running on a separate worker - TLS implementation should be ported to not use java API like buffers (it's almost so) and the most serious problem is trust certificate store access
r
@cy I thought to take https://github.com/daltoniam/Starscream implementation and take “transport” part from there
c
Iam not certain, if cocoapods well supported in KN. Doesn't it require copying and committing 3rd party source code anymore?
Does it support TLS?
r
as of this source it uses
Foundation
only, which is part of iOS and MacOs
yes, it supports TLS
• WebSocket tasks exchange messages over TCP and TLS, using the WebSocket protocol defined in RFC 6455.
but this is only apple specific code, I don’t know about other platforms
Copy code
public convenience init(request: URLRequest, certPinner: CertificatePinning? = FoundationSecurity(), compressionHandler: CompressionHandler? = nil, useCustomEngine: Bool = true) {
        if #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *), !useCustomEngine {
            self.init(request: request, engine: NativeEngine())
        } else if #available(macOS 10.14, iOS 12.0, watchOS 5.0, tvOS 12.0, *) {
            self.init(request: request, engine: WSEngine(transport: TCPTransport(), certPinner: certPinner, compressionHandler: compressionHandler))
        } else {
            self.init(request: request, engine: WSEngine(transport: FoundationTransport(), certPinner: certPinner, compressionHandler: compressionHandler))
        }
    }
c
The problem with copying source codes is the potential licensing violations. We prefer to not copy rather than risk as we are not lawyers and nobody can guarantee anything
👍 1
r
code will not be copied I just showed approach been used what I’m planning to use
but what the right entry point? where I have to put my coding approach to create a PR? I can see
ktor/ktor-client/ktor-client-ios/darwin/src/io/ktor/client/engine/ios/
creating a
IosWebSocket.kt
in this folder will be ok?
or it should be part of
ktor/ktor-client/ktor-client-cio/common/src/io/ktor/client/engine/
?
@cy do you think is bad idea to do my development with this approach?
c
Sorry for delay. I think it's good because we don't know when CIO will work properly on native. It will take time so it makes sense to have an alternative solution
I'll point to the right place later where you should start from
r
@cy thank you
@cy could you just show a good example of WebSocket implementation?
@cy or according to this https://github.com/ktorio/ktor/pull/2247 better to wait a little bit for a native CIO?