How to Make and Receive WebRTC Calls
Warning: Beta software This API is in beta stage and may be subject to change. Therefore, we do not recommend using this in production.
Interested in this feature? Please reach out to mobility-services-developer@cisco.com
Prerequisites
Overview
This API makes it possible to register a WebRTC terminal (or just Terminal) with our (voice) core, and then use it to make and receive calls just like a mobile phone does.
In other words, the API enables development of a software phone fully integrated with our core.
Required Scope
call.control.answer_and_initiate
Code Dependencies
<dependency>
<groupId>com.wgtwo.api.v0.grpc</groupId>
<artifactId>webterminal</artifactId>
<version>0.3.0</version>
</dependency>
Code
#!/usr/bin/env bash
grpcurl \
-d '
{
"offer": {
"sdp": "",
"msisdn": {
"e164": "+1234567890"
}
},
"callId": "b5289ac4-d254-4d75-8b45-a8c5f5cf47b0"
}
' \
sandbox.api.shamrock.wgtwo.com:443 \
wgtwo.webterminal.v0.WebTerminalService/Pipe
package com.example.webterminal
import com.wgtwo.api.v0.common.PhoneNumberProto
import com.wgtwo.api.v0.webterminal.WebTerminalMessage
import com.wgtwo.api.v0.webterminal.WebTerminalServiceGrpcKt
import io.grpc.ManagedChannelBuilder
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.catch
import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.flow.onCompletion
import kotlinx.coroutines.runBlocking
import java.util.UUID
@ExperimentalCoroutinesApi
fun main() {
val channel = ManagedChannelBuilder.forAddress("sandbox.api.shamrock.wgtwo.com", 443).build()
val stub = WebTerminalServiceGrpcKt.WebTerminalServiceCoroutineStub(channel)
// your calles's MSISDN goes here
val to = "1234567890"
// your SDP goes here
val sdp = ""
// Pipe() ignores callId, but it's mandatory for MultiPipe()
val callId = UUID.randomUUID().toString()
// building Offer
val toPhone = PhoneNumberProto.PhoneNumber.newBuilder().setE164(to).build()
val offer = WebTerminalMessage.newBuilder().apply {
offerBuilder.also {
it.msisdn = toPhone
it.sdp = sdp
}
this.callId = callId
}.build()
val requests = flow<WebTerminalMessage> {
emit(offer)
}
runBlocking {
stub.pipe(requests).onCompletion {
println("stream closed")
}.catch { t ->
println("got error $t")
}.collect {
println("got message $it")
}
}
}
Example Result
{
"idle": {}
}
got message idle {
}
stream closed