Commit ca711647 authored by Dele Olajide's avatar Dele Olajide Committed by dele

Rayo plugin work-in-progress

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/trunk@13757 b35dd754-fafc-0310-a699-88a17e54d16e
parent 1a6c79e9
......@@ -111,7 +111,7 @@
};
CandyBar.prototype.setState = function (state) {
if (!this.dom) return this;
if (!this.dom) return this;
var buttons = this.dom.querySelectorAll('button'),
callActionsEl = this.dom.querySelector('.callActions'),
self = this,
......@@ -137,10 +137,9 @@
forEach.call(buttons, function (button) {
button.parentElement.removeChild(button);
});
// add buttons
stateDef.buttons.forEach(function (button) {
callActionsEl.appendChild(self.domify('<button class="' + button.cls + '">' + button.label + '</button>'));
stateDef.buttons.forEach(function (button) {
callActionsEl.appendChild(self.domify('<button class="' + button.cls + '">' + button.label + '</button>'));
});
// start/stop timer
......
......@@ -288,7 +288,7 @@ body {
display: block;
position: relative; }
.cancel {
.cancel_dialer {
position: absolute;
top: 4px;
right: 10px;
......
......@@ -109,25 +109,33 @@
{
window.connection.rayo.phone(
{
onReady: function() {
console.log('Handset is off hook');
offHook: function() {
$("#status").html("Off Hook");
},
onUnready: function() {
console.log('Handset is on hook');
onHook: function() {
$("#status").html("On Hook");
},
offSpeaking: function() {
$("#status").html("Stopped Speaking");
},
onSpeaking: function() {
$("#status").html("Started Speaking");
},
onOffer: function(call, headers) {
console.log('onOffer ' + call.from);
console.log(headers);
//console.log('onOffer ' + call.from);
//console.log(headers);
if (window.candybar.call == null) // ignore when user has active call
{
var cli = headers['caller-name'] ? headers['caller-name']: call.from;
window.candybar.setUser({
name: call.from,
number: call.to,
name: cli,
number: cli,
picUrl: 'unknown.jpg'
});
......@@ -135,21 +143,24 @@
window.candybar.setState('incoming');
window.dialer.setCallLabel('Answer');
}
startTone("Diggztone_Vibe");
},
onEnd: function(callId, headers) {
console.log('onEnd ' + callId);
console.log(headers);
//console.log('onEnd ' + callId);
//console.log(headers);
window.candybar.endGently();
window.candybar.call = null;
window.dialer.setCallLabel('Call');
stopTone();
},
onAnswer: function(callId, headers) {
console.log('onAnswer ' + callId);
console.log(headers);
//console.log('onAnswer ' + callId);
//console.log(headers);
window.candybar.setState('active');
window.dialer.setCallLabel('Hangup');
......@@ -157,8 +168,8 @@
},
onRing: function(callId, headers) {
console.log('onRing ' + callId);
console.log(headers);
//console.log('onRing ' + callId);
//console.log(headers);
window.candybar.setState('calling');
startTone("ringback-uk");
......@@ -177,36 +188,20 @@
var sipUri = prefix + destination + "@" + domain
if (prefix == "sip:") sipUri = prefix + destination + "@" + domain
if (prefix == "tel:") sipUri = prefix + destination
if (prefix == "xmpp:") sipUri = prefix + destination + "@" + domain + "/" + destination;
window.candybar.call = window.connection.rayo.dial("xmpp:" + window.connection.jid, sipUri);
window.candybar.setUser({
name: sipUri,
name: destination,
number: destination,
picUrl: 'unknown.jpg'
});
}
function onIncomingCall(call)
{
console.log(' call from ' + call.from);
if (window.candybar.call == null) // ignore when user has active call
{
window.candybar.setUser({
name: call.from,
number: call.to,
picUrl: 'unknown.jpg'
});
window.candybar.call = call;
window.candybar.setState('incoming');
window.dialer.setCallLabel('Answer');
}
}
function urlParam(name)
{
var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(window.location.href);
......@@ -216,10 +211,13 @@
function startTone(name)
{
ringtone = new Audio();
ringtone.loop = true;
ringtone.src = "ringtones/" + name + ".mp3";
ringtone.play();
if (!ringtone)
{
ringtone = new Audio();
ringtone.loop = true;
ringtone.src = "ringtones/" + name + ".mp3";
ringtone.play();
}
}
function stopTone()
......
......@@ -51,16 +51,16 @@ Strophe.addConnectionPlugin('rayo',
hangup: function(callId)
{
console.log("hangup " + callId);
//console.log("hangup " + callId);
var that = this;
var iq = $iq({to: callId + "@rayo." + this._connection.domain, from: this._connection.jid, type: "get"}).c("hangup", {xmlns: Strophe.NS.RAYO_CORE});
console.log(iq.toString());
//console.log(iq.toString());
that._connection.sendIQ(iq, function(response)
{
console.log(response);
//console.log(response);
if ($(response).attr('type') != "result")
{
......@@ -87,18 +87,18 @@ Strophe.addConnectionPlugin('rayo',
});
},
answer: function(callId, headers)
answer: function(callId, mixer, headers)
{
//console.log('Rayo plugin accept ' + callId);
//console.log('Rayo plugin accept ' + callId + " " + mixer);
//console.log(headers)
var that = this;
if (this._isOffhook()) this._onhook();
//if (this._isOffhook()) this._onhook();
this._offhook(callId, headers, function()
this._offhook(mixer, headers, function()
{
var iq = $iq({to: "rayo." + that._connection.domain, from: that._connection.jid, type: "get"}).c("answer", {xmlns: Strophe.NS.RAYO_CORE});
var iq = $iq({to: callId + "@rayo." + that._connection.domain, from: that._connection.jid, type: "get"}).c("answer", {xmlns: Strophe.NS.RAYO_CORE});
if (headers)
{
......@@ -113,7 +113,7 @@ Strophe.addConnectionPlugin('rayo',
}
}
console.log(iq.toString());
//console.log(iq.toString());
that._connection.sendIQ(iq, function(response)
{
......@@ -131,12 +131,18 @@ Strophe.addConnectionPlugin('rayo',
//console.log(headers)
var that = this;
var mixer = "rayo-mixer-" + Math.random().toString(36).substr(2,9);
var callId = "rayo-call-" + Math.random().toString(36).substr(2,9);
if (this._isOffhook()) this._onhook();
if (to.indexOf("xmpp:") == 0)
{
callId = Strophe.escapeNode(to.substring(5));
}
//if (this._isOffhook()) this._onhook();
this._offhook(callId, headers, function()
this._offhook(mixer, headers, function()
{
var iq = $iq({to: "rayo." + that._connection.domain, from: that._connection.jid, type: "get"}).c("dial", {xmlns: Strophe.NS.RAYO_CORE, to: to, from: from});
......@@ -155,7 +161,7 @@ Strophe.addConnectionPlugin('rayo',
}
}
console.log(iq.toString());
//console.log(iq.toString());
that._connection.sendIQ(iq, function(response)
{
......@@ -206,7 +212,16 @@ Strophe.addConnectionPlugin('rayo',
//console.log('Rayo plugin _offhook1 ' + mixer);
var that = this;
that.pc1 = new webkitRTCPeerConnection(null);
that.pc1 = new webkitRTCPeerConnection(null);
that.pc2 = new webkitRTCPeerConnection(null);
that.pc2.onaddstream = function(e)
{
that.audio = new Audio();
that.audio.autoplay = true;
that.audio.src = webkitURL.createObjectURL(e.stream)
};
that.pc1.addStream(that.localStream);
that.pc1.createOffer(function(desc)
......@@ -234,16 +249,7 @@ Strophe.addConnectionPlugin('rayo',
that._offhook2(mixer, headers, action);
});
});
that.pc2 = new webkitRTCPeerConnection(null);
that.pc2.onaddstream = function(e)
{
that.audio = new Audio();
that.audio.autoplay = true;
that.audio.src = webkitURL.createObjectURL(e.stream)
};
});
},
_offhook2: function(mixer, headers, action)
......@@ -318,7 +324,8 @@ Strophe.addConnectionPlugin('rayo',
var value = $(this).attr('value');
headers[name] = value;
});
});
$(presence).find('complete').each(function()
{
......@@ -336,19 +343,21 @@ Strophe.addConnectionPlugin('rayo',
if ($(this).attr('xmlns') == Strophe.NS.RAYO_CORE)
{
var callFrom = $(this).attr('from');
var callTo = $(this).attr('value');
var callTo = $(this).attr('to');
var callId = Strophe.getNodeFromJid(from);
var mixer = headers['mixer-name']
var call = {
digit: function(tone) {that.digit(callId, tone);},
hangup: function() {that.hangup(callId);},
answer: function(callId, headers) {that.answer(callId, headers);},
digit: function(tone) {that.digit(callId, tone);},
hangup: function() {that.hangup(callId);},
answer: function() {that.answer(callId, mixer, headers);},
from: callFrom,
to: callTo,
to: callTo,
id: callId
}
if (that.callbacks && that.callbacks.onOffer) that.callbacks.onOffer(call, headers);
var iq = $iq({to: from, from: that._connection.jid, type: "get"}).c("accept", {xmlns: Strophe.NS.RAYO_CORE});
......@@ -389,17 +398,32 @@ Strophe.addConnectionPlugin('rayo',
{
}
});
$(presence).find('started-speaking').each(function()
{
if ($(this).attr('xmlns') == Strophe.NS.RAYO_CORE)
{
var callId = Strophe.getNodeFromJid(from);
if (that.callbacks && that.callbacks.onSpeaking) that.callbacks.onSpeaking(callId, headers);
}
});
$(presence).find('ringing').each(function()
$(presence).find('stopped-speaking').each(function()
{
if ($(this).attr('xmlns') == Strophe.NS.RAYO_CORE)
{
if (that.handsetId != Strophe.getNodeFromJid(from))
{
var callId = Strophe.getNodeFromJid(from);
if (that.callbacks && that.callbacks.onRing) that.callbacks.onRing(callId, headers);
}
{
var callId = Strophe.getNodeFromJid(from);
if (that.callbacks && that.callbacks.offSpeaking) that.callbacks.offSpeaking(callId, headers);
}
});
$(presence).find('ringing').each(function()
{
if ($(this).attr('xmlns') == Strophe.NS.RAYO_CORE)
{
var callId = Strophe.getNodeFromJid(from);
if (that.callbacks && that.callbacks.onRing) that.callbacks.onRing(callId, headers);
}
});
......@@ -407,30 +431,28 @@ Strophe.addConnectionPlugin('rayo',
{
if ($(this).attr('xmlns') == Strophe.NS.RAYO_CORE)
{
if (that.handsetId != Strophe.getNodeFromJid(from))
{
var callId = Strophe.getNodeFromJid(from);
if (that.callbacks && that.callbacks.onAnswer) that.callbacks.onAnswer(callId, headers);
var callId = Strophe.getNodeFromJid(from);
if (headers['call-protocol'] == "WebRtc")
{
if (that.callbacks && that.callbacks.offHook) that.callbacks.offHook();
} else {
if (that.callbacks && that.callbacks.onReady) that.callbacks.onReady();
}
if (that.callbacks && that.callbacks.onAnswer) that.callbacks.onAnswer(callId, headers);
}
}
});
$(presence).find('end').each(function()
{
{
if ($(this).attr('xmlns') == Strophe.NS.RAYO_CORE)
{
if (that.handsetId != Strophe.getNodeFromJid(from))
{
var callId = Strophe.getNodeFromJid(from);
if (that.callbacks && that.callbacks.onEnd) that.callbacks.onEnd(callId, headers);
} else {
if (that.callbacks && that.callbacks.onUnready) that.callbacks.onUnready();
}
{
var callId = Strophe.getNodeFromJid(from);
that._onhook();
if (that.callbacks && that.callbacks.onHook) that.callbacks.onHook();
if (that.callbacks && that.callbacks.onEnd) that.callbacks.onEnd(callId, headers);
}
});
......
......@@ -90,7 +90,7 @@ public class CallParticipant {
private String remoteMediaInfo = null;
private ProxyCredentials proxyCredentials = null;
private RelayChannel relayChannel = null;
private boolean autoAnswer = true;
private boolean autoAnswer = false;
private long startTimestamp = 0;
private long endTimestamp = 0;
private Map<String, String> headers = new HashMap<String, String>();
......
......@@ -376,6 +376,7 @@ public class RayoComponent extends AbstractComponent
IQ reply = IQ.createResultIQ(iq);
Map<String, String> headers = command.getHeaders();
headers.put("call-protocol", "XMPP");
try {
Presence presence = new Presence();
......@@ -398,17 +399,22 @@ public class RayoComponent extends AbstractComponent
IQ reply = IQ.createResultIQ(iq);
Map<String, String> headers = command.getHeaders();
headers.put("call-protocol", "XMPP");
try {
String handsetId = JID.escapeNode(iq.getFrom().toString());
Presence presence = new Presence();
presence.setFrom(iq.getTo());
presence.setTo(JID.unescapeNode(iq.getTo().getNode()));
presence.getElement().add(rayoProvider.toXML(new AnsweredEvent(null, headers)));
sendPacket(presence);
Presence presence1 = new Presence(); //to caller
presence1.setFrom(iq.getTo());
presence1.setTo(JID.unescapeNode(iq.getTo().getNode()));
presence1.getElement().add(rayoProvider.toXML(new AnsweredEvent(null, headers)));
sendPacket(presence1);
Presence presence2 = new Presence(); //to called
presence2.setFrom(iq.getTo());
presence2.setTo(iq.getFrom());
presence2.getElement().add(rayoProvider.toXML(new AnsweredEvent(null, headers)));
sendPacket(presence2);
String handsetId = iq.getTo().getNode(); // use mixer of caller
RelayChannel channel = plugin.getRelayChannel(handsetId);
if (channel != null)
......@@ -435,14 +441,21 @@ public class RayoComponent extends AbstractComponent
String recording = handset.mixer + "-" + cp.getStartTimestamp() + ".au";
conferenceManager.recordConference(true, recording, "au");
Config.createCallRecord(username, recording, "xmpp:" + iq.getFrom().toString(), cp.getStartTimestamp(), 0, "dialed") ;
String source = (new JID(JID.unescapeNode(iq.getTo().getNode()))).getNode();
String destination = iq.getFrom().getNode();
Config.createCallRecord(source, recording, destination, cp.getStartTimestamp(), 0, "dialed") ;
Config.createCallRecord(destination, recording, source, cp.getStartTimestamp(), 0, "received") ;
} catch (ParseException e1) {
reply.setError(PacketError.Condition.internal_server_error);
}
}
}
}
} else reply.setError(PacketError.Condition.item_not_found);
} else reply.setError(PacketError.Condition.item_not_found);
} else reply.setError(PacketError.Condition.item_not_found);
} catch (Exception e) {
reply.setError(PacketError.Condition.item_not_found);
......@@ -454,18 +467,37 @@ public class RayoComponent extends AbstractComponent
private IQ handleHangupCommand(IQ iq)
{
Log.info("RayoComponent handleHangupCommand " + iq.getFrom());
String callId = iq.getTo().getNode();
Log.info("RayoComponent handleHangupCommand " + iq.getFrom() + " " + callId);
IQ reply = IQ.createResultIQ(iq);
try {
CallHandler callHandler = CallHandler.findCall(iq.getTo().getNode());
CallHandler callHandler = CallHandler.findCall(callId);
if (callHandler != null)
{
Log.info("RayoComponent handleHangupCommand found callhandler " + callId);
CallHandler.hangup(iq.getTo().getNode(), "User requested call termination");
} catch (NoSuchElementException e) {
} else {
reply.setError(PacketError.Condition.item_not_found);
}
try {
JID otherParty = new JID(JID.unescapeNode(callId));
Log.info("RayoComponent handleHangupCommand found other party " + otherParty);
Presence presence1 = new Presence();
presence1.setFrom(iq.getTo());
presence1.setTo(otherParty);
presence1.getElement().add(rayoProvider.toXML(new EndEvent(null, null)));
sendPacket(presence1);
} catch (Exception e) { }
return reply;
}
......@@ -591,14 +623,14 @@ public class RayoComponent extends AbstractComponent
headers.put("caller-name", callerName);
}
if (calledName == null)
{
calledName = to;
headers.put("called-name", calledName);
}
if (toPhone)
{
if (calledName == null)
{
calledName = to;
headers.put("called-name", calledName);
}
CallParticipant cp = new CallParticipant();
cp.setVoiceDetection(true);
cp.setCallOwner(handsetId);
......@@ -614,30 +646,50 @@ public class RayoComponent extends AbstractComponent
} else if (toXmpp){
headers.put("call-protocol", "XMPP");
String destination = to.substring(5);
String mixer = JID.escapeNode(destination);
String source = JID.escapeNode(handsetId);
Presence presence = new Presence();
presence.setFrom(mixer + "@rayo." + getDomain());
presence.setTo(new JID(destination));
RelayChannel channel = plugin.getRelayChannel(source); // user mixer of caller
headers.put("mixer-name", mixer);
if (channel != null)
{
headers.put("mixer-name", channel.getHandset().mixer);
OfferEvent offer = new OfferEvent(callId);
Presence presence = new Presence();
presence.setFrom(source + "@rayo." + getDomain());
presence.setTo(new JID(destination));
try {
offer.setFrom(new URI("xmpp:" + iq.getFrom().toString()));
offer.setTo(new URI(to));
OfferEvent offer = new OfferEvent(callId);
} catch (URISyntaxException e) {
reply.setError(PacketError.Condition.feature_not_implemented);
return reply;
}
try {
offer.setFrom(new URI("xmpp:" + iq.getFrom().toString()));
offer.setTo(new URI(to));
} catch (URISyntaxException e) {
reply.setError(PacketError.Condition.feature_not_implemented);
return reply;
}
offer.setHeaders(headers);
if (calledName == null)
{
calledName = presence.getTo().getNode();
headers.put("called-name", calledName);
}
presence.getElement().add(rayoProvider.toXML(offer));
sendPacket(presence);
offer.setHeaders(headers);
presence.getElement().add(rayoProvider.toXML(offer));
sendPacket(presence);
final Element childElement = reply.setChildElement("ref", "urn:xmpp:rayo:1");
childElement.addAttribute(URI, (String) "xmpp:" + destination);
childElement.addAttribute(ID, (String) JID.escapeNode(destination));
} else {
reply.setError(PacketError.Condition.item_not_found);
}
} else {
reply.setError(PacketError.Condition.feature_not_implemented);
......@@ -873,6 +925,7 @@ public class RayoComponent extends AbstractComponent
headers.put("call-id", callEvent.getCallId());
headers.put("mixer-name", callEvent.getConferenceId());
headers.put("call-protocol", cp.getProtocol());
Presence presence = new Presence();
presence.setFrom(callEvent.getCallId() + "@rayo." + getDomain());
......@@ -880,7 +933,7 @@ public class RayoComponent extends AbstractComponent
if ("001 STATE CHANGED".equals(myEvent))
{
if ("110 ANSWERED".equals(callState)) {
if ("100 INVITED".equals(callState)) {
presence.getElement().add(rayoProvider.toXML(new RingingEvent(null, headers)));
sendPacket(presence);
......
......@@ -51,16 +51,16 @@ Strophe.addConnectionPlugin('rayo',
hangup: function(callId)
{
console.log("hangup " + callId);
//console.log("hangup " + callId);
var that = this;
var iq = $iq({to: callId + "@rayo." + this._connection.domain, from: this._connection.jid, type: "get"}).c("hangup", {xmlns: Strophe.NS.RAYO_CORE});
console.log(iq.toString());
//console.log(iq.toString());
that._connection.sendIQ(iq, function(response)
{
console.log(response);
//console.log(response);
if ($(response).attr('type') != "result")
{
......@@ -87,18 +87,18 @@ Strophe.addConnectionPlugin('rayo',
});
},
answer: function(callId, headers)
answer: function(callId, mixer, headers)
{
//console.log('Rayo plugin accept ' + callId);
//console.log('Rayo plugin accept ' + callId + " " + mixer);
//console.log(headers)
var that = this;
if (this._isOffhook()) this._onhook();
//if (this._isOffhook()) this._onhook();
this._offhook(callId, headers, function()
this._offhook(mixer, headers, function()
{
var iq = $iq({to: "rayo." + that._connection.domain, from: that._connection.jid, type: "get"}).c("answer", {xmlns: Strophe.NS.RAYO_CORE});
var iq = $iq({to: callId + "@rayo." + that._connection.domain, from: that._connection.jid, type: "get"}).c("answer", {xmlns: Strophe.NS.RAYO_CORE});
if (headers)
{
......@@ -113,7 +113,7 @@ Strophe.addConnectionPlugin('rayo',
}
}
console.log(iq.toString());
//console.log(iq.toString());
that._connection.sendIQ(iq, function(response)
{
......@@ -131,12 +131,18 @@ Strophe.addConnectionPlugin('rayo',
//console.log(headers)
var that = this;
var mixer = "rayo-mixer-" + Math.random().toString(36).substr(2,9);
var callId = "rayo-call-" + Math.random().toString(36).substr(2,9);
if (this._isOffhook()) this._onhook();
if (to.indexOf("xmpp:") == 0)
{
callId = Strophe.escapeNode(to.substring(5));
}
//if (this._isOffhook()) this._onhook();
this._offhook(callId, headers, function()
this._offhook(mixer, headers, function()
{
var iq = $iq({to: "rayo." + that._connection.domain, from: that._connection.jid, type: "get"}).c("dial", {xmlns: Strophe.NS.RAYO_CORE, to: to, from: from});
......@@ -155,7 +161,7 @@ Strophe.addConnectionPlugin('rayo',
}
}
console.log(iq.toString());
//console.log(iq.toString());
that._connection.sendIQ(iq, function(response)
{
......@@ -206,7 +212,16 @@ Strophe.addConnectionPlugin('rayo',
//console.log('Rayo plugin _offhook1 ' + mixer);
var that = this;
that.pc1 = new webkitRTCPeerConnection(null);
that.pc1 = new webkitRTCPeerConnection(null);
that.pc2 = new webkitRTCPeerConnection(null);
that.pc2.onaddstream = function(e)
{
that.audio = new Audio();
that.audio.autoplay = true;
that.audio.src = webkitURL.createObjectURL(e.stream)
};
that.pc1.addStream(that.localStream);
that.pc1.createOffer(function(desc)
......@@ -234,16 +249,7 @@ Strophe.addConnectionPlugin('rayo',
that._offhook2(mixer, headers, action);
});
});
that.pc2 = new webkitRTCPeerConnection(null);
that.pc2.onaddstream = function(e)
{
that.audio = new Audio();
that.audio.autoplay = true;
that.audio.src = webkitURL.createObjectURL(e.stream)
};
});
},
_offhook2: function(mixer, headers, action)
......@@ -318,7 +324,8 @@ Strophe.addConnectionPlugin('rayo',
var value = $(this).attr('value');
headers[name] = value;
});
});
$(presence).find('complete').each(function()
{
......@@ -336,19 +343,21 @@ Strophe.addConnectionPlugin('rayo',
if ($(this).attr('xmlns') == Strophe.NS.RAYO_CORE)
{
var callFrom = $(this).attr('from');
var callTo = $(this).attr('value');
var callTo = $(this).attr('to');
var callId = Strophe.getNodeFromJid(from);
var mixer = headers['mixer-name']
var call = {
digit: function(tone) {that.digit(callId, tone);},
hangup: function() {that.hangup(callId);},
answer: function(callId, headers) {that.answer(callId, headers);},
digit: function(tone) {that.digit(callId, tone);},
hangup: function() {that.hangup(callId);},
answer: function() {that.answer(callId, mixer, headers);},
from: callFrom,
to: callTo,
to: callTo,
id: callId
}
if (that.callbacks && that.callbacks.onOffer) that.callbacks.onOffer(call, headers);
var iq = $iq({to: from, from: that._connection.jid, type: "get"}).c("accept", {xmlns: Strophe.NS.RAYO_CORE});
......@@ -389,17 +398,32 @@ Strophe.addConnectionPlugin('rayo',
{
}
});
$(presence).find('started-speaking').each(function()
{
if ($(this).attr('xmlns') == Strophe.NS.RAYO_CORE)
{
var callId = Strophe.getNodeFromJid(from);
if (that.callbacks && that.callbacks.onSpeaking) that.callbacks.onSpeaking(callId, headers);
}
});
$(presence).find('ringing').each(function()
$(presence).find('stopped-speaking').each(function()
{
if ($(this).attr('xmlns') == Strophe.NS.RAYO_CORE)
{
if (that.handsetId != Strophe.getNodeFromJid(from))
{
var callId = Strophe.getNodeFromJid(from);
if (that.callbacks && that.callbacks.onRing) that.callbacks.onRing(callId, headers);
}
{
var callId = Strophe.getNodeFromJid(from);
if (that.callbacks && that.callbacks.offSpeaking) that.callbacks.offSpeaking(callId, headers);
}
});
$(presence).find('ringing').each(function()
{
if ($(this).attr('xmlns') == Strophe.NS.RAYO_CORE)
{
var callId = Strophe.getNodeFromJid(from);
if (that.callbacks && that.callbacks.onRing) that.callbacks.onRing(callId, headers);
}
});
......@@ -407,30 +431,28 @@ Strophe.addConnectionPlugin('rayo',
{
if ($(this).attr('xmlns') == Strophe.NS.RAYO_CORE)
{
if (that.handsetId != Strophe.getNodeFromJid(from))
{
var callId = Strophe.getNodeFromJid(from);
if (that.callbacks && that.callbacks.onAnswer) that.callbacks.onAnswer(callId, headers);
var callId = Strophe.getNodeFromJid(from);
if (headers['call-protocol'] == "WebRtc")
{
if (that.callbacks && that.callbacks.offHook) that.callbacks.offHook();
} else {
if (that.callbacks && that.callbacks.onReady) that.callbacks.onReady();
}
if (that.callbacks && that.callbacks.onAnswer) that.callbacks.onAnswer(callId, headers);
}
}
});
$(presence).find('end').each(function()
{
{
if ($(this).attr('xmlns') == Strophe.NS.RAYO_CORE)
{
if (that.handsetId != Strophe.getNodeFromJid(from))
{
var callId = Strophe.getNodeFromJid(from);
if (that.callbacks && that.callbacks.onEnd) that.callbacks.onEnd(callId, headers);
} else {
if (that.callbacks && that.callbacks.onUnready) that.callbacks.onUnready();
}
{
var callId = Strophe.getNodeFromJid(from);
that._onhook();
if (that.callbacks && that.callbacks.onHook) that.callbacks.onHook();
if (that.callbacks && that.callbacks.onEnd) that.callbacks.onEnd(callId, headers);
}
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment