Copy
grpcurl \
-d '
{
"offer": {
"sdp": "",
"msisdn": {
"e164": "+1234567890"
}
},
"callId": "b5289ac4-d254-4d75-8b45-a8c5f5cf47b0"
}
' \
sandbox.api.shamrock.wgtwo.com:443 \
wgtwo.webterminal.v0.WebTerminalService/Pipe
Copy
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")
}
}
}