hi I am trying to use multiple event channel to stream data from native side to flutter in iOS swift side when I call the below for setting handler we only get one callback and I want some way to differentiate that which eventsink that I am getting is for Eventchannel1 or EventChannel2
let EventChannel1 = FlutterEventChannel(name: "stream1",binaryMessenger: controller.binaryMessenger)
let EventChannel2 = FlutterEventChannel(name: "stream2",binaryMessenger: controller.binaryMessenger)
EventChannel1.setStreamHandler(self)
EventChannel2.setStreamHandler(self)
then the related callback we get this
func onListen(withArguments arguments: Any?,
eventSink: @escaping FlutterEventSink) -> FlutterError? {
debugPrint("On Listen Call")
EventSink = eventSink//this is for the old event channel now I am using
//two event channel.
//and don't know how to know which event channel is which. on flutter
//app startup I listen both stream.
//and the "on Listen Call" which I print to console print two times
//which indicate the I am listen to both stream.
//but here I don't know how I know if the eventsink is for which event channel.
//I want some condition here but don,t know how to implement. if possible
//something like this if eventchanel.name == eventchannel1
//so that I know which event channel event sink it is and handle it according.
return nil
}
func onCancel(withArguments arguments: Any?) -> FlutterError? {
debugPrint("On cancel Call")
EventSink = nil
return nil
}
if the question is not clear let me know so that I can explain it more clearly .
selffor both cases?