Skip to content

DataChannel

Ajša Terko edited this page Sep 22, 2023 · 1 revision



dataChannelEventListener

Description

Configures the event handler for data channel events.

Example

let applicationCall = InfobipRTC.getActiveApplicationCall()
applicationCall.dataChannel()?.dataChannelEventListener = self



send(text, completionHandler)

Description

Sends data through the data channel to other call participants who have enabled the use of the data channel.

Arguments

  • 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 an ErrorCode in case the sending is unsuccessful.

Returns

  • N/A

Example

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)")
        }
    }
}



send(text, to, completionHandler)

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.

Arguments

  • 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 an ErrorCode in case the sending is unsuccessful.

Returns

  • N/A

Example

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)")
        }
    }
}

Tutorials

Migration guides

Reference documentation

Clone this wiki locally