mirror of
https://github.com/zhigang1992/fal-swift.git
synced 2026-01-12 22:47:17 +08:00
* feat: initial high fps sample * fix: remove prints * feat: realtime turbo camera demo * fix: fps count * chore: docs and build update * fix: remove non-exported targets * feat: binary realtime protocol with msgpack * fix: update macos support to v13 * chore: rename ObjectValue to Payload
22 lines
720 B
Swift
22 lines
720 B
Swift
import Dispatch
|
|
import Foundation
|
|
|
|
public extension Realtime {
|
|
func connect<Input: Encodable, Output: Decodable>(
|
|
to app: String,
|
|
connectionKey: String = UUID().uuidString,
|
|
throttleInterval: DispatchTimeInterval = .milliseconds(64),
|
|
onResult completion: @escaping (Result<Output, Error>) -> Void
|
|
) throws -> TypedRealtimeConnection<Input> {
|
|
handleConnection(
|
|
to: app,
|
|
connectionKey: connectionKey,
|
|
throttleInterval: throttleInterval,
|
|
connectionFactory: { send, close in
|
|
TypedRealtimeConnection(send, close)
|
|
},
|
|
onResult: completion
|
|
) as! TypedRealtimeConnection<Input>
|
|
}
|
|
}
|