private void call(Transaction transaction, JsonObject params)
throws IOException {
String to = params.get("callTo").getAsString();
Session toSession = registry.get(to).getSession();
JsonObject icParams = new JsonObject();
params.addProperty("from", name);
JsonObject icResponse = (JsonObject) toSession.sendRequest(
"incommingCall", icParams);
String callResponse = icResponse.get("callResponse").getAsString();
if ("Accept".equals(callResponse)) {
log.info("Accepted call from '{}' to '{}'", name, to);
call = new Call(mpf);
call.setOutgoingPeer(name, session);
call.setIncommingPeer(to, toSession);
String ipSdpOffer = icResponse.get("sdpOffer").getAsString();
log.info("SdpOffer: {}", ipSdpOffer);
String ipSdpAnswer = call.getWebRtcForIncommingPeer().processOffer(
ipSdpOffer);
JsonObject scParams = new JsonObject();
scParams.addProperty("sdpAnswer", ipSdpAnswer);
log.info("SdpAnswer: {}", ipSdpAnswer);
// TODO Should we expect something from client?
toSession.sendRequest("startCommunication", scParams);
String opSdpOffer = params.getAsJsonPrimitive("sdpOffer")
.getAsString();
String opSdpAnswer = call.getWebRtcForOutgoingPeer().processOffer(