Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions Sources/FlutterSwiftOCA/OcaChannelManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import Logging
import SwiftOCA

public let OcaChannelPrefix = "oca/"
public let OcaPlatformStateReadyMethodName = "platform_ready"

private let OcaMeteringSubscriptionLabel = "com.padl.FlutterSwiftOCA.metering"

Expand Down Expand Up @@ -56,6 +57,7 @@ Sendable {
private let sampleRateChannel: FlutterMethodChannel
private let datasetChannel: FlutterMethodChannel // storing param datasets in a remote slot
private let datasetBlobChannel: FlutterMethodChannel // fetching param datasets as a blob
private let platformStateChannel: FlutterMethodChannel // report platform channel status

// event channels
private let propertyEventChannel: FlutterEventChannel
Expand Down Expand Up @@ -145,6 +147,10 @@ Sendable {
name: "\(OcaChannelPrefix)dataset",
binaryMessenger: binaryMessenger
)
platformStateChannel = FlutterMethodChannel(
name: "\(OcaChannelPrefix)platform_state",
binaryMessenger: binaryMessenger
)
propertyEventChannel = FlutterEventChannel(
name: "\(OcaChannelPrefix)property_event",
binaryMessenger: binaryMessenger
Expand Down Expand Up @@ -182,6 +188,13 @@ Sendable {
try propertyEventChannel.resizeChannelBuffer(propertyEventChannelBufferSize)
try meteringEventChannel.allowChannelBufferOverflow(true)
try connectionStateChannel.allowChannelBufferOverflow(true)

logger.trace("OCA platform channels ready")

Task{
// let Flutter code know it is safe to subsribe to the channels above
try await platformStateChannel.invoke(method: OcaPlatformStateReadyMethodName, arguments: true)
}
}

public func connect() async throws {
Expand Down