Commit 4330588a 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@13763 b35dd754-fafc-0310-a699-88a17e54d16e
parent 7692b193
...@@ -20,10 +20,13 @@ ...@@ -20,10 +20,13 @@
var domain = "81.201.82.25"; var domain = "81.201.82.25";
var prefix = "sip:"; var prefix = "sip:";
var ringtone; var ringtone;
var username = null;
var password = null;
var jid = window.location.hostname;
window.dialer = new Dialpad({ window.dialer = new Dialpad({
onPress: function (key) { onPress: function (key) {
console.log('a key was pressed', key); //console.log('a key was pressed', key);
if (window.candybar.call) window.candybar.call.digit(key); if (window.candybar.call) window.candybar.call.digit(key);
}, },
...@@ -32,12 +35,12 @@ ...@@ -32,12 +35,12 @@
//makeCall(number); //makeCall(number);
}, },
onHide: function () { onHide: function () {
console.log('removed it'); //console.log('removed it');
}, },
onCall: function (number) { onCall: function (number) {
if (window.dialer.getCallLabel() == "Call") { if (window.dialer.getCallLabel() == "Call") {
console.log('The call button was pressed', number); //console.log('The call button was pressed', number);
makeCall(number); makeCall(number);
} else if (window.dialer.getCallLabel() == "Hangup") { } else if (window.dialer.getCallLabel() == "Hangup") {
...@@ -60,6 +63,8 @@ ...@@ -60,6 +63,8 @@
if (urlParam("prefix")) prefix = urlParam("prefix"); if (urlParam("prefix")) prefix = urlParam("prefix");
if (urlParam("domain")) domain = urlParam("domain"); if (urlParam("domain")) domain = urlParam("domain");
if (urlParam("username")) username = urlParam("username");
if (urlParam("password")) password = urlParam("password");
if (domain == "81.201.82.25" && prefix == "sip:") prefix = "sip:883510"; if (domain == "81.201.82.25" && prefix == "sip:") prefix = "sip:883510";
if (prefix == "tel:") domain = ""; if (prefix == "tel:") domain = "";
...@@ -71,10 +76,17 @@ ...@@ -71,10 +76,17 @@
{ {
iNum = Math.random().toString(36).substr(2,9); iNum = Math.random().toString(36).substr(2,9);
} }
if (username && password)
{
iNum = username;
jid = username + "@" + window.location.hostname
}
window.connection = new Openfire.Connection(window.location.protocol + '//' + window.location.host + '/http-bind/'); window.connection = new Openfire.Connection(window.location.protocol + '//' + window.location.host + '/http-bind/');
window.connection.resource = iNum; window.connection.resource = iNum;
window.connection.connect(window.location.hostname, null, function (status) window.connection.connect(jid, password, function (status)
{ {
//console.log("XMPPConnection.connect"); //console.log("XMPPConnection.connect");
//console.log(status); //console.log(status);
...@@ -89,21 +101,21 @@ ...@@ -89,21 +101,21 @@
}); });
setPhone(); setPhone();
}
});
var destination = urlParam("destination"); var destination = urlParam("destination");
if (destination) if (destination)
{ {
makeCall(destination); makeCall(destination);
} }
}
});
}) })
function setPhone() function setPhone()
{ {
console.log("setPhone()"); //console.log("setPhone()");
if (window.connection) if (window.connection)
{ {
...@@ -128,6 +140,11 @@ ...@@ -128,6 +140,11 @@
$("#status").html("Started Speaking"); $("#status").html("Started Speaking");
}, },
onAccept: function(call) {
window.candybar.call = call;
},
onOffer: function(call, headers) { onOffer: function(call, headers) {
//console.log('onOffer ' + call.from); //console.log('onOffer ' + call.from);
//console.log(headers); //console.log(headers);
...@@ -178,7 +195,16 @@ ...@@ -178,7 +195,16 @@
startTone("ringback-uk"); startTone("ringback-uk");
}, },
onJoin: function(jid, mixer) {
//console.log('onJoin ' + jid + " " + mixer);
},
onUnjoin: function(jid, mixer) {
//console.log('onUnjoin ' + jid + " " + mixer);
},
onError: function(e) { onError: function(e) {
console.error(e); console.error(e);
} }
}); });
...@@ -187,7 +213,7 @@ ...@@ -187,7 +213,7 @@
function makeCall(destination) function makeCall(destination)
{ {
console.log("makeCall " + destination); //console.log("makeCall " + destination);
var sipUri = prefix + destination + "@" + domain var sipUri = prefix + destination + "@" + domain
...@@ -196,7 +222,7 @@ ...@@ -196,7 +222,7 @@
if (prefix == "xmpp:") sipUri = prefix + destination + "@" + domain + "/" + destination; if (prefix == "xmpp:") sipUri = prefix + destination + "@" + domain + "/" + destination;
window.candybar.call = window.connection.rayo.dial("xmpp:" + window.connection.jid, sipUri, { window.connection.rayo.dial("xmpp:" + window.connection.jid, sipUri, {
codec_name: "PCMU", codec_name: "PCMU",
}); });
......
...@@ -58,14 +58,13 @@ Strophe.addConnectionPlugin('rayo', ...@@ -58,14 +58,13 @@ Strophe.addConnectionPlugin('rayo',
//console.log(iq.toString()); //console.log(iq.toString());
that._connection.sendIQ(iq, function(response) that._connection.sendIQ(iq, null, function(error)
{ {
//console.log(response); $('error', error).each(function()
if ($(response).attr('type') != "result")
{ {
if (that.callbacks && that.callbacks.onError) that.callbacks.onError("hangup failure"); var errorcode = $(this).attr('code');
} if (that.callbacks && that.callbacks.onError) that.callbacks.onError("hangup failure " + errorcode);
});
}); });
this._onhook(); this._onhook();
...@@ -78,12 +77,13 @@ Strophe.addConnectionPlugin('rayo', ...@@ -78,12 +77,13 @@ Strophe.addConnectionPlugin('rayo',
var that = this; var that = this;
var iq = $iq({to: callId + "@rayo." + this._connection.domain, from: this._connection.jid, type: "get"}).c("dtmf", {xmlns: Strophe.NS.RAYO_CORE, tones: key}); var iq = $iq({to: callId + "@rayo." + this._connection.domain, from: this._connection.jid, type: "get"}).c("dtmf", {xmlns: Strophe.NS.RAYO_CORE, tones: key});
that._connection.sendIQ(iq, function(response) that._connection.sendIQ(iq, null, function(error)
{ {
if ($(response).attr('type') != "result") $('error', error).each(function()
{ {
if (that.callbacks && that.callbacks.onError) that.callbacks.onError("dtmf failure"); var errorcode = $(this).attr('code');
} if (that.callbacks && that.callbacks.onError) that.callbacks.onError("dtmf failure " + errorcode);
});
}); });
}, },
...@@ -115,12 +115,14 @@ Strophe.addConnectionPlugin('rayo', ...@@ -115,12 +115,14 @@ Strophe.addConnectionPlugin('rayo',
//console.log(iq.toString()); //console.log(iq.toString());
that._connection.sendIQ(iq, function(response) that._connection.sendIQ(iq, null, function(error)
{ {
if ($(response).attr('type') != "result") $('error', error).each(function()
{ {
if (that.callbacks && that.callbacks.onError) that.callbacks.onError("answer failure"); var errorcode = $(this).attr('code');
} if (that._isOffhook()) that._onhook();
if (that.callbacks && that.callbacks.onError) that.callbacks.onError("answer failure " + errorcode);
});
}); });
}); });
}, },
...@@ -140,7 +142,7 @@ Strophe.addConnectionPlugin('rayo', ...@@ -140,7 +142,7 @@ Strophe.addConnectionPlugin('rayo',
callId = Strophe.escapeNode(to.substring(5)); callId = Strophe.escapeNode(to.substring(5));
} }
//if (this._isOffhook()) this._onhook(); if (this._isOffhook()) this._onhook();
this._offhook(mixer, headers, function() this._offhook(mixer, headers, function()
{ {
...@@ -163,24 +165,38 @@ Strophe.addConnectionPlugin('rayo', ...@@ -163,24 +165,38 @@ Strophe.addConnectionPlugin('rayo',
//console.log(iq.toString()); //console.log(iq.toString());
that._connection.sendIQ(iq, function(response) that._connection.sendIQ(iq, function(response) {
{
if ($(response).attr('type') != "result") $('ref', response).each(function()
{ {
if (that.callbacks && that.callbacks.onError) that.callbacks.onError("dial failure"); callId = $(this).attr('id');
}
});
});
return { if (that.callbacks && that.callbacks.onAccept)
digit: function(tone) {that.digit(callId, tone);}, {
hangup: function() {that.hangup(callId);}, that.callbacks.onAccept(
{
digit: function(tone) {that.digit(callId, tone);},
hangup: function() {that.hangup(callId);},
from: from,
to: to,
id: callId
});
}
});
from: from, }, function(error){
to: to,
id: callId $('error', error).each(function()
} {
var errorcode = $(this).attr('code');
if (that._isOffhook()) that._onhook();
if (that.callbacks && that.callbacks.onError) that.callbacks.onError("dial failure " + errorcode);
});
that._onhook();
});
});
}, },
...@@ -267,32 +283,31 @@ Strophe.addConnectionPlugin('rayo', ...@@ -267,32 +283,31 @@ Strophe.addConnectionPlugin('rayo',
var that = this; var that = this;
var stereo = (headers && headers.stereo_pan) ? headers.stereo_pan : (that.callbacks.stereo_pan ? that.callbacks.stereo_pan : "0"); var stereo = (headers && headers.stereo_pan) ? headers.stereo_pan : (that.callbacks.stereo_pan ? that.callbacks.stereo_pan : "0");
var codec = (headers && headers.codec_name) ? headers.codec_name : (that.callbacks.codec_name ? that.callbacks.codec_name : "OPUS"); var codec = (headers && headers.codec_name) ? headers.codec_name : (that.callbacks.codec_name ? that.callbacks.codec_name : "OPUS");
var group = (headers && headers.group_name) ? headers.group_name : "";
var iq = $iq({to: "rayo." + that._connection.domain, from: that._connection.jid, type: "get"}).c("offhook", {xmlns: Strophe.NS.RAYO_HANDSET, cryptoSuite: that.cryptoSuite, localCrypto: that.localCrypto, remoteCrypto: that.remoteCrypto, codec: codec, stereo: stereo, mixer: mixer}); var iq = $iq({to: "rayo." + that._connection.domain, from: that._connection.jid, type: "get"}).c("offhook", {xmlns: Strophe.NS.RAYO_HANDSET, cryptoSuite: that.cryptoSuite, localCrypto: that.localCrypto, remoteCrypto: that.remoteCrypto, codec: codec, stereo: stereo, mixer: mixer, group: group});
//console.log(iq.toString()) //console.log(iq.toString())
that._connection.sendIQ(iq, function(response) that._connection.sendIQ(iq, function(response)
{ {
if ($(response).attr('type') == "result") $('ref', response).each(function()
{ {
$('ref', response).each(function() that.handsetId = $(this).attr('id');
{ that.handsetUri = $(this).attr('uri');
that.handsetId = $(this).attr('id'); that.relayHost = $(this).attr('host');
that.handsetUri = $(this).attr('uri'); that.relayLocalPort = $(this).attr('localport');
that.relayHost = $(this).attr('host'); that.relayRemotePort = $(this).attr('remoteport');
that.relayLocalPort = $(this).attr('localport');
that.relayRemotePort = $(this).attr('remoteport');
that.pc2.addIceCandidate(new RTCIceCandidate({sdpMLineIndex: "0", candidate: "a=candidate:3707591233 1 udp 2113937151 " + that.relayHost + " " + that.relayRemotePort + " typ host generation 0"}));
that.pc1.addIceCandidate(new RTCIceCandidate({sdpMLineIndex: "0", candidate: "a=candidate:3707591233 1 udp 2113937151 " + that.relayHost + " " + that.relayLocalPort + " typ host generation 0"}));
action(); that.pc2.addIceCandidate(new RTCIceCandidate({sdpMLineIndex: "0", candidate: "a=candidate:3707591233 1 udp 2113937151 " + that.relayHost + " " + that.relayRemotePort + " typ host generation 0"}));
}); that.pc1.addIceCandidate(new RTCIceCandidate({sdpMLineIndex: "0", candidate: "a=candidate:3707591233 1 udp 2113937151 " + that.relayHost + " " + that.relayLocalPort + " typ host generation 0"}));
} else { action();
if (that.callbacks && that.callbacks.onError) that.callbacks.onError("offhook failure"); });
}
}, function (error) {
if (that.callbacks && that.callbacks.onError) that.callbacks.onError("offhook failure");
}); });
}, },
...@@ -311,7 +326,7 @@ Strophe.addConnectionPlugin('rayo', ...@@ -311,7 +326,7 @@ Strophe.addConnectionPlugin('rayo',
that.pc1.close(); that.pc1.close();
that.pc2.close(); that.pc2.close();
that.pc1 = null; that.pc1 = null;
that.pc2 = null; that.pc2 = null;
}); });
}, },
...@@ -382,12 +397,13 @@ Strophe.addConnectionPlugin('rayo', ...@@ -382,12 +397,13 @@ Strophe.addConnectionPlugin('rayo',
//console.log(iq.toString()); //console.log(iq.toString());
that._connection.sendIQ(iq, function(response) that._connection.sendIQ(iq, null, function(error)
{ {
if ($(response).attr('type') != "result") $('error', error).each(function()
{ {
if (that.callbacks && that.callbacks.onError) that.callbacks.onError("accept failure"); var errorcode = $(this).attr('code');
} if (that.callbacks && that.callbacks.onError) that.callbacks.onError("accept failure " + errorcode);
});
}); });
} }
}) })
...@@ -395,22 +411,36 @@ Strophe.addConnectionPlugin('rayo', ...@@ -395,22 +411,36 @@ Strophe.addConnectionPlugin('rayo',
$(presence).find('joined').each(function() $(presence).find('joined').each(function()
{ {
if ($(this).attr('xmlns') == Strophe.NS.RAYO_CORE) if ($(this).attr('xmlns') == Strophe.NS.RAYO_CORE)
{ {
var callId = Strophe.getNodeFromJid(from);
var jid = Strophe.unescapeNode(callId);
if (jid.indexOf("@") > -1 && jid.indexOf("/") > -1)
{
if (that.callbacks && that.callbacks.onJoin) that.callbacks.onJoin(jid, $(this).attr('mixer-name'));
}
} }
}); });
$(presence).find('unjoined').each(function() $(presence).find('unjoined').each(function()
{ {
if ($(this).attr('xmlns') == Strophe.NS.RAYO_CORE) if ($(this).attr('xmlns') == Strophe.NS.RAYO_CORE)
{ {
var callId = Strophe.getNodeFromJid(from); var callId = Strophe.getNodeFromJid(from);
var jid = Strophe.unescapeNode(callId);
if (callId.indexOf("rayo-incoming-") == 0) if (jid.indexOf("@") > -1 && jid.indexOf("/") > -1)
{ {
that._onhook(); if (that.callbacks && that.callbacks.onUnjoin) that.callbacks.onUnjoin(jid, $(this).attr('mixer-name'));
if (that.callbacks && that.callbacks.onEnd) that.callbacks.onEnd(callId, headers); } else {
if (callId.indexOf("rayo-incoming-") == 0)
{
that._onhook();
if (that.callbacks && that.callbacks.onEnd) that.callbacks.onEnd(callId, headers);
}
} }
} }
}); });
......
...@@ -49,6 +49,8 @@ public class Handset extends BaseVerb { ...@@ -49,6 +49,8 @@ public class Handset extends BaseVerb {
@NotNull(message=Handset.MISSING_MIXER) @NotNull(message=Handset.MISSING_MIXER)
public String mixer; public String mixer;
public String group;
public Handset(String cryptoSuite, String localCrypto, String remoteCrypto, String codec, String stereo, String mixer) public Handset(String cryptoSuite, String localCrypto, String remoteCrypto, String codec, String stereo, String mixer)
{ {
this.cryptoSuite = cryptoSuite; this.cryptoSuite = cryptoSuite;
......
...@@ -76,7 +76,9 @@ public class HandsetProvider extends BaseProvider { ...@@ -76,7 +76,9 @@ public class HandsetProvider extends BaseProvider {
element.attributeValue("stereo"), element.attributeValue("stereo"),
element.attributeValue("mixer")); element.attributeValue("mixer"));
OffHookCommand command = new OffHookCommand(); handset.group = element.attributeValue("group");
OffHookCommand command = new OffHookCommand();
command.setHandset(handset); command.setHandset(handset);
return command; return command;
......
...@@ -516,14 +516,28 @@ public class ConferenceManager { ...@@ -516,14 +516,28 @@ public class ConferenceManager {
return displayName; return displayName;
} }
public static String getDisplayName(String conferenceId) { public void setDisplayName(String displayName) {
try { this.displayName = displayName;
ConferenceManager conferenceManager = }
findConferenceManager(conferenceId);
return conferenceManager.getDisplayName(); public static String getDisplayName(String conferenceId)
} catch (ParseException e) { {
return null; try {
} ConferenceManager conferenceManager = findConferenceManager(conferenceId);
return conferenceManager.getDisplayName();
} catch (ParseException e) {
return null;
}
}
public static void setDisplayName(String conferenceId, String displayName)
{
try {
ConferenceManager conferenceManager = findConferenceManager(conferenceId);
conferenceManager.setDisplayName(displayName);
} catch (ParseException e) {
}
} }
public void setPermanent(boolean permanent) { public void setPermanent(boolean permanent) {
......
...@@ -580,7 +580,7 @@ public class ConferenceMember implements TreatmentDoneListener, ...@@ -580,7 +580,7 @@ public class ConferenceMember implements TreatmentDoneListener,
} }
conferenceManager.joinDistributedConference(this); conferenceManager.joinDistributedConference(this);
joinedDistributedConference = true; joinedDistributedConference = false;
} }
public void reinitialize(ConferenceManager conferenceManager) { public void reinitialize(ConferenceManager conferenceManager) {
......
...@@ -58,14 +58,13 @@ Strophe.addConnectionPlugin('rayo', ...@@ -58,14 +58,13 @@ Strophe.addConnectionPlugin('rayo',
//console.log(iq.toString()); //console.log(iq.toString());
that._connection.sendIQ(iq, function(response) that._connection.sendIQ(iq, null, function(error)
{ {
//console.log(response); $('error', error).each(function()
if ($(response).attr('type') != "result")
{ {
if (that.callbacks && that.callbacks.onError) that.callbacks.onError("hangup failure"); var errorcode = $(this).attr('code');
} if (that.callbacks && that.callbacks.onError) that.callbacks.onError("hangup failure " + errorcode);
});
}); });
this._onhook(); this._onhook();
...@@ -78,12 +77,13 @@ Strophe.addConnectionPlugin('rayo', ...@@ -78,12 +77,13 @@ Strophe.addConnectionPlugin('rayo',
var that = this; var that = this;
var iq = $iq({to: callId + "@rayo." + this._connection.domain, from: this._connection.jid, type: "get"}).c("dtmf", {xmlns: Strophe.NS.RAYO_CORE, tones: key}); var iq = $iq({to: callId + "@rayo." + this._connection.domain, from: this._connection.jid, type: "get"}).c("dtmf", {xmlns: Strophe.NS.RAYO_CORE, tones: key});
that._connection.sendIQ(iq, function(response) that._connection.sendIQ(iq, null, function(error)
{ {
if ($(response).attr('type') != "result") $('error', error).each(function()
{ {
if (that.callbacks && that.callbacks.onError) that.callbacks.onError("dtmf failure"); var errorcode = $(this).attr('code');
} if (that.callbacks && that.callbacks.onError) that.callbacks.onError("dtmf failure " + errorcode);
});
}); });
}, },
...@@ -115,12 +115,14 @@ Strophe.addConnectionPlugin('rayo', ...@@ -115,12 +115,14 @@ Strophe.addConnectionPlugin('rayo',
//console.log(iq.toString()); //console.log(iq.toString());
that._connection.sendIQ(iq, function(response) that._connection.sendIQ(iq, null, function(error)
{ {
if ($(response).attr('type') != "result") $('error', error).each(function()
{ {
if (that.callbacks && that.callbacks.onError) that.callbacks.onError("answer failure"); var errorcode = $(this).attr('code');
} if (that._isOffhook()) that._onhook();
if (that.callbacks && that.callbacks.onError) that.callbacks.onError("answer failure " + errorcode);
});
}); });
}); });
}, },
...@@ -140,7 +142,7 @@ Strophe.addConnectionPlugin('rayo', ...@@ -140,7 +142,7 @@ Strophe.addConnectionPlugin('rayo',
callId = Strophe.escapeNode(to.substring(5)); callId = Strophe.escapeNode(to.substring(5));
} }
//if (this._isOffhook()) this._onhook(); if (this._isOffhook()) this._onhook();
this._offhook(mixer, headers, function() this._offhook(mixer, headers, function()
{ {
...@@ -163,24 +165,38 @@ Strophe.addConnectionPlugin('rayo', ...@@ -163,24 +165,38 @@ Strophe.addConnectionPlugin('rayo',
//console.log(iq.toString()); //console.log(iq.toString());
that._connection.sendIQ(iq, function(response) that._connection.sendIQ(iq, function(response) {
{
if ($(response).attr('type') != "result") $('ref', response).each(function()
{ {
if (that.callbacks && that.callbacks.onError) that.callbacks.onError("dial failure"); callId = $(this).attr('id');
}
});
});
return { if (that.callbacks && that.callbacks.onAccept)
digit: function(tone) {that.digit(callId, tone);}, {
hangup: function() {that.hangup(callId);}, that.callbacks.onAccept(
{
digit: function(tone) {that.digit(callId, tone);},
hangup: function() {that.hangup(callId);},
from: from,
to: to,
id: callId
});
}
});
from: from, }, function(error){
to: to,
id: callId $('error', error).each(function()
} {
var errorcode = $(this).attr('code');
if (that._isOffhook()) that._onhook();
if (that.callbacks && that.callbacks.onError) that.callbacks.onError("dial failure " + errorcode);
});
that._onhook();
});
});
}, },
...@@ -267,32 +283,31 @@ Strophe.addConnectionPlugin('rayo', ...@@ -267,32 +283,31 @@ Strophe.addConnectionPlugin('rayo',
var that = this; var that = this;
var stereo = (headers && headers.stereo_pan) ? headers.stereo_pan : (that.callbacks.stereo_pan ? that.callbacks.stereo_pan : "0"); var stereo = (headers && headers.stereo_pan) ? headers.stereo_pan : (that.callbacks.stereo_pan ? that.callbacks.stereo_pan : "0");
var codec = (headers && headers.codec_name) ? headers.codec_name : (that.callbacks.codec_name ? that.callbacks.codec_name : "OPUS"); var codec = (headers && headers.codec_name) ? headers.codec_name : (that.callbacks.codec_name ? that.callbacks.codec_name : "OPUS");
var group = (headers && headers.group_name) ? headers.group_name : "";
var iq = $iq({to: "rayo." + that._connection.domain, from: that._connection.jid, type: "get"}).c("offhook", {xmlns: Strophe.NS.RAYO_HANDSET, cryptoSuite: that.cryptoSuite, localCrypto: that.localCrypto, remoteCrypto: that.remoteCrypto, codec: codec, stereo: stereo, mixer: mixer}); var iq = $iq({to: "rayo." + that._connection.domain, from: that._connection.jid, type: "get"}).c("offhook", {xmlns: Strophe.NS.RAYO_HANDSET, cryptoSuite: that.cryptoSuite, localCrypto: that.localCrypto, remoteCrypto: that.remoteCrypto, codec: codec, stereo: stereo, mixer: mixer, group: group});
//console.log(iq.toString()) //console.log(iq.toString())
that._connection.sendIQ(iq, function(response) that._connection.sendIQ(iq, function(response)
{ {
if ($(response).attr('type') == "result") $('ref', response).each(function()
{ {
$('ref', response).each(function() that.handsetId = $(this).attr('id');
{ that.handsetUri = $(this).attr('uri');
that.handsetId = $(this).attr('id'); that.relayHost = $(this).attr('host');
that.handsetUri = $(this).attr('uri'); that.relayLocalPort = $(this).attr('localport');
that.relayHost = $(this).attr('host'); that.relayRemotePort = $(this).attr('remoteport');
that.relayLocalPort = $(this).attr('localport');
that.relayRemotePort = $(this).attr('remoteport');
that.pc2.addIceCandidate(new RTCIceCandidate({sdpMLineIndex: "0", candidate: "a=candidate:3707591233 1 udp 2113937151 " + that.relayHost + " " + that.relayRemotePort + " typ host generation 0"}));
that.pc1.addIceCandidate(new RTCIceCandidate({sdpMLineIndex: "0", candidate: "a=candidate:3707591233 1 udp 2113937151 " + that.relayHost + " " + that.relayLocalPort + " typ host generation 0"}));
action(); that.pc2.addIceCandidate(new RTCIceCandidate({sdpMLineIndex: "0", candidate: "a=candidate:3707591233 1 udp 2113937151 " + that.relayHost + " " + that.relayRemotePort + " typ host generation 0"}));
}); that.pc1.addIceCandidate(new RTCIceCandidate({sdpMLineIndex: "0", candidate: "a=candidate:3707591233 1 udp 2113937151 " + that.relayHost + " " + that.relayLocalPort + " typ host generation 0"}));
} else { action();
if (that.callbacks && that.callbacks.onError) that.callbacks.onError("offhook failure"); });
}
}, function (error) {
if (that.callbacks && that.callbacks.onError) that.callbacks.onError("offhook failure");
}); });
}, },
...@@ -311,7 +326,7 @@ Strophe.addConnectionPlugin('rayo', ...@@ -311,7 +326,7 @@ Strophe.addConnectionPlugin('rayo',
that.pc1.close(); that.pc1.close();
that.pc2.close(); that.pc2.close();
that.pc1 = null; that.pc1 = null;
that.pc2 = null; that.pc2 = null;
}); });
}, },
...@@ -382,12 +397,13 @@ Strophe.addConnectionPlugin('rayo', ...@@ -382,12 +397,13 @@ Strophe.addConnectionPlugin('rayo',
//console.log(iq.toString()); //console.log(iq.toString());
that._connection.sendIQ(iq, function(response) that._connection.sendIQ(iq, null, function(error)
{ {
if ($(response).attr('type') != "result") $('error', error).each(function()
{ {
if (that.callbacks && that.callbacks.onError) that.callbacks.onError("accept failure"); var errorcode = $(this).attr('code');
} if (that.callbacks && that.callbacks.onError) that.callbacks.onError("accept failure " + errorcode);
});
}); });
} }
}) })
...@@ -395,22 +411,36 @@ Strophe.addConnectionPlugin('rayo', ...@@ -395,22 +411,36 @@ Strophe.addConnectionPlugin('rayo',
$(presence).find('joined').each(function() $(presence).find('joined').each(function()
{ {
if ($(this).attr('xmlns') == Strophe.NS.RAYO_CORE) if ($(this).attr('xmlns') == Strophe.NS.RAYO_CORE)
{ {
var callId = Strophe.getNodeFromJid(from);
var jid = Strophe.unescapeNode(callId);
if (jid.indexOf("@") > -1 && jid.indexOf("/") > -1)
{
if (that.callbacks && that.callbacks.onJoin) that.callbacks.onJoin(jid, $(this).attr('mixer-name'));
}
} }
}); });
$(presence).find('unjoined').each(function() $(presence).find('unjoined').each(function()
{ {
if ($(this).attr('xmlns') == Strophe.NS.RAYO_CORE) if ($(this).attr('xmlns') == Strophe.NS.RAYO_CORE)
{ {
var callId = Strophe.getNodeFromJid(from); var callId = Strophe.getNodeFromJid(from);
var jid = Strophe.unescapeNode(callId);
if (callId.indexOf("rayo-incoming-") == 0) if (jid.indexOf("@") > -1 && jid.indexOf("/") > -1)
{ {
that._onhook(); if (that.callbacks && that.callbacks.onUnjoin) that.callbacks.onUnjoin(jid, $(this).attr('mixer-name'));
if (that.callbacks && that.callbacks.onEnd) that.callbacks.onEnd(callId, headers); } else {
if (callId.indexOf("rayo-incoming-") == 0)
{
that._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