-
Notifications
You must be signed in to change notification settings - Fork 3
DataChannel
Ajša Terko edited this page Sep 22, 2023
·
1 revision
dataChannelEventListener: DataChannelEventListener?
send(text: String, _ completionHandler: @escaping (String?, ErrorCode?) -> Void))
send(text: String, to: Endpoint, _ completionHandler: @escaping (String?, ErrorCode?) -> Void))
Configures the event handler for data channel events.
let applicationCall = InfobipRTC.getActiveApplicationCall()
applicationCall.dataChannel()?.dataChannelEventListener = self
Sends data through the data channel to other call participants who have enabled the use of the data channel.
-
text
:String
- Data to be sent through the data channel. -
completionHandler
:(String?, ErrorCode?) -> Void
- Completion handler optionally receiving an ID of the sent text or anErrorCode
in case the sending is unsuccessful.
N/A
let infobipRTC: InfobipRTC = getInfobipRTCInstance()
if let call = infobipRTC.getActiveRoomCall() as? RoomCall {
call.send(text: "Hello World!") { id, errorCode in
if let errorCode = errorCode {
print("An error has occurred: \(errorCode.description)")
}
}
}
Directly sends data through the data channel to a chosen endpoint participating in a call. This method ensures that the text is only sent to the chosen recipient and therefore is not received by other call participants.
-
text
:String
- Data to be sent through the data channel. -
to
:Endpoint
- Endpoint to which data is to be sent directly. -
completionHandler
:(String?, ErrorCode?) -> Void
- Completion handler optionally receiving an ID of the text which was sent or anErrorCode
in case the sending is unsuccessful.
N/A
let infobipRTC: InfobipRTC = getInfobipRTCInstance()
if let call = infobipRTC.getActiveCall() as? WebrtcCall {
call.send(text: "Hello", to: call.counterpart()) { id, errorCode in
if let errorCode = errorCode {
print("An error has occurred: \(errorCode.description)")
}
}
}