Commit 315325ed authored by Dele Olajide's avatar Dele Olajide Committed by dele

Rayo plugin - Implemented SayCommand

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/trunk@13794 b35dd754-fafc-0310-a699-88a17e54d16e
parent 5b146019
...@@ -68,10 +68,18 @@ ...@@ -68,10 +68,18 @@
{ {
cls: 'redirect', cls: 'redirect',
label: 'Redirect Call' label: 'Redirect Call'
},
{
cls: 'say',
label: 'Say Message'
},
{
cls: 'pause',
label: 'Pause say'
}, },
{ {
cls: 'private', cls: 'resume',
label: 'Private Call' label: 'Resume say'
}], }],
timer: true timer: true
}, },
...@@ -98,6 +106,7 @@ ...@@ -98,6 +106,7 @@
cls: 'leave', cls: 'leave',
label: 'Leave Call' label: 'Leave Call'
}], }],
timer: true
}, },
inactive: { inactive: {
buttons: [], buttons: [],
...@@ -278,7 +287,22 @@ ...@@ -278,7 +287,22 @@
if (self.call) { if (self.call) {
self.call.redirect(prompt("Please enter new destination:","sip:xxxx@domain.com")); self.call.redirect(prompt("Please enter new destination:","sip:xxxx@domain.com"));
} }
};
self.say = function () {
if (self.call) {
self.call.say(prompt("Please enter message:","tts:hello world, i love you"));
}
};
self.pause = function () {
if (self.call.saying) {
self.call.saying.pause();
}
}; };
self.resume = function () {
if (self.call.saying) {
self.call.saying.resume();
}
};
self.mute = function () { self.mute = function () {
if (self.call) { if (self.call) {
self.call.mute(true); self.call.mute(true);
......
...@@ -149,7 +149,7 @@ ...@@ -149,7 +149,7 @@
{ {
window.connection.rayo.phone( window.connection.rayo.phone(
{ {
codec_name: "PCMU", codec_name: "OPUS",
stereo_pan: "0", stereo_pan: "0",
sip_handset: sipHandset, sip_handset: sipHandset,
...@@ -211,8 +211,11 @@ ...@@ -211,8 +211,11 @@
//console.log('onAnswer ' + callId); //console.log('onAnswer ' + callId);
//console.log(headers); //console.log(headers);
window.candybar.setState('active'); if (window.candybar.redirect != callId)
window.dialer.setCallLabel('Hangup'); {
window.candybar.setState('active');
window.dialer.setCallLabel('Hangup');
}
stopTone(); stopTone();
}, },
...@@ -270,7 +273,7 @@ ...@@ -270,7 +273,7 @@
}, },
offMute: function(callId) { offMute: function(callId) {
console.log('offMute ' + callId); //console.log('offMute ' + callId);
window.candybar.setState('active'); window.candybar.setState('active');
window.dialer.setCallLabel('Hangup'); window.dialer.setCallLabel('Hangup');
...@@ -291,15 +294,27 @@ ...@@ -291,15 +294,27 @@
}, },
onRedirect: function(callId) { onRedirect: function(callId) {
//console.log('onRedirect ' + callId); console.log('onRedirect ' + callId);
window.candybar.endGently(); window.candybar.endGently();
window.candybar.call = null; window.candybar.redirect = callId;
window.dialer.setCallLabel('Call'); window.dialer.setCallLabel('Call');
stopTone(); stopTone();
}, },
onSay: function(saying) {
console.log('Started saying ' + saying.sayId);
window.candybar.call.saying = saying;
},
onSayComplete: function(sayId) {
console.log('Finished saying ' + sayId);
window.candybar.call.saying = null;
},
onError: function(e) { onError: function(e) {
console.error(e); console.error(e);
...@@ -326,8 +341,8 @@ ...@@ -326,8 +341,8 @@
if (!username) groupname = null; if (!username) groupname = null;
window.connection.rayo.dial("xmpp:" + window.connection.jid, sipUri, { window.connection.rayo.dial("xmpp:" + window.connection.jid, sipUri, {
codec_name: "PCMU", codec_name: "OPUS",
group_name: groupname //group_name: groupname
}); });
window.candybar.setUser({ window.candybar.setUser({
......
...@@ -63,7 +63,9 @@ Strophe.addConnectionPlugin('rayo', ...@@ -63,7 +63,9 @@ Strophe.addConnectionPlugin('rayo',
that._onhook(); that._onhook();
}, function(error) { }, function(error) {
that._onhook();
$('error', error).each(function() $('error', error).each(function()
{ {
var errorcode = $(this).attr('code'); var errorcode = $(this).attr('code');
...@@ -77,7 +79,7 @@ Strophe.addConnectionPlugin('rayo', ...@@ -77,7 +79,7 @@ Strophe.addConnectionPlugin('rayo',
//console.log("Rayo plugin digit " + callId + " " + key); //console.log("Rayo plugin digit " + callId + " " + key);
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 + "@" + this._connection.domain, from: this._connection.jid, type: "get"}).c("dtmf", {xmlns: Strophe.NS.RAYO_CORE, tones: key});
that._connection.sendIQ(iq, null, function(error) that._connection.sendIQ(iq, null, function(error)
{ {
...@@ -114,7 +116,7 @@ Strophe.addConnectionPlugin('rayo', ...@@ -114,7 +116,7 @@ Strophe.addConnectionPlugin('rayo',
//console.log("hold " + callId); //console.log("hold " + callId);
var that = this; var that = this;
var iq = $iq({to: callId + "@rayo." + this._connection.domain, from: this._connection.jid, type: "get"}).c("hold", {xmlns: Strophe.NS.RAYO_HANDSET}); var iq = $iq({to: callId + "@" + this._connection.domain, from: this._connection.jid, type: "get"}).c("hold", {xmlns: Strophe.NS.RAYO_HANDSET});
//console.log(iq.toString()); //console.log(iq.toString());
...@@ -133,12 +135,12 @@ Strophe.addConnectionPlugin('rayo', ...@@ -133,12 +135,12 @@ Strophe.addConnectionPlugin('rayo',
}); });
}, },
redirect: function(to, mixer, headers) redirect: function(to, headers)
{ {
//console.log("redirect " + to + " " + mixer); //console.log("redirect " + to);
var that = this; var that = this;
var iq = $iq({to: callId + "@rayo." + this._connection.domain, from: this._connection.jid, type: "get"}).c("redirect", {xmlns: Strophe.NS.RAYO_CORE, to: to}); var iq = $iq({to: this._connection.domain, from: this._connection.jid, type: "get"}).c("redirect", {xmlns: Strophe.NS.RAYO_CORE, to: to});
if (headers) if (headers)
{ {
...@@ -176,12 +178,68 @@ Strophe.addConnectionPlugin('rayo', ...@@ -176,12 +178,68 @@ Strophe.addConnectionPlugin('rayo',
}); });
}, },
say: function(callId, message)
{
//console.log('Rayo plugin say ' + callId + " " + message);
var that = this;
var iq = $iq({to: callId + "@" + this._connection.domain, from: this._connection.jid, type: "get"}).c( "say", {xmlns: Strophe.NS.RAYO_SAY}).t(message);
that._connection.sendIQ(iq, function(response)
{
$('ref', response).each(function()
{
var sayId = $(this).attr('id');
var node = Strophe.escapeNode(callId + "@" + that._connection.domain + "/" + sayId);
if (that.callbacks && that.callbacks.onSay) that.callbacks.onSay(
{
sayId: sayId,
pause: function()
{
that._connection.sendIQ($iq({to: node + "@" + that._connection.domain, from: that._connection.jid, type: "get"}).c( "pause", {xmlns: Strophe.NS.RAYO_SAY}), function(response){}, null, function(error){
$('error', error).each(function()
{
var errorcode = $(this).attr('code');
if (that.callbacks && that.callbacks.onError) that.callbacks.onError("pause failure " + errorcode);
});
});
},
resume: function()
{
that._connection.sendIQ($iq({to: node + "@" + that._connection.domain, from: that._connection.jid, type: "get"}).c( "resume", {xmlns: Strophe.NS.RAYO_SAY}), null, function(error){
$('error', error).each(function()
{
var errorcode = $(this).attr('code');
if (that.callbacks && that.callbacks.onError) that.callbacks.onError("resume failure " + errorcode);
});
});
}
});
});
}, function(error) {
$('error', error).each(function()
{
var errorcode = $(this).attr('code');
if (that.callbacks && that.callbacks.onError) that.callbacks.onError("say failure " + errorcode);
});
});
},
private: function(callId, flag) private: function(callId, flag)
{ {
//console.log('Rayo plugin private ' + callId + " " + flag); //console.log('Rayo plugin private ' + callId + " " + flag);
var that = this; var that = this;
var iq = $iq({to: callId + "@rayo." + this._connection.domain, from: this._connection.jid, type: "get"}).c( flag ? "private" : "public", {xmlns: Strophe.NS.RAYO_HANDSET}); var iq = $iq({to: callId + "@" + this._connection.domain, from: this._connection.jid, type: "get"}).c( flag ? "private" : "public", {xmlns: Strophe.NS.RAYO_HANDSET});
that._connection.sendIQ(iq, null, function(error) that._connection.sendIQ(iq, null, function(error)
{ {
...@@ -192,14 +250,14 @@ Strophe.addConnectionPlugin('rayo', ...@@ -192,14 +250,14 @@ Strophe.addConnectionPlugin('rayo',
}); });
}); });
}, },
mute: function(callId, flag) mute: function(callId, flag)
{ {
//console.log('Rayo plugin mute ' + callId + " " + flag); //console.log('Rayo plugin mute ' + callId + " " + flag);
var that = this; var that = this;
var iq = $iq({to: callId + "@rayo." + this._connection.domain, from: this._connection.jid, type: "get"}).c( flag ? "mute" : "unmute", {xmlns: Strophe.NS.RAYO_HANDSET}); var iq = $iq({to: callId + "@" + this._connection.domain, from: this._connection.jid, type: "get"}).c( flag ? "mute" : "unmute", {xmlns: Strophe.NS.RAYO_HANDSET});
that._connection.sendIQ(iq, null, function(error) that._connection.sendIQ(iq, null, function(error)
{ {
...@@ -227,7 +285,7 @@ Strophe.addConnectionPlugin('rayo', ...@@ -227,7 +285,7 @@ Strophe.addConnectionPlugin('rayo',
this._offhook(mixer, headers, function() this._offhook(mixer, headers, function()
{ {
var iq = $iq({to: callId + "@rayo." + that._connection.domain, from: that._connection.jid, type: "get"}).c("answer", {xmlns: Strophe.NS.RAYO_CORE}); var iq = $iq({to: callId + "@" + that._connection.domain, from: that._connection.jid, type: "get"}).c("answer", {xmlns: Strophe.NS.RAYO_CORE});
var hdrs = Object.getOwnPropertyNames(headers) var hdrs = Object.getOwnPropertyNames(headers)
...@@ -298,7 +356,8 @@ Strophe.addConnectionPlugin('rayo', ...@@ -298,7 +356,8 @@ Strophe.addConnectionPlugin('rayo',
that.callbacks.onAccept( that.callbacks.onAccept(
{ {
digit: function(tone) {that.digit(callId, tone);}, digit: function(tone) {that.digit(callId, tone);},
redirect: function(to) {that.redirect(to, mixer, headers);}, redirect: function(to) {that.redirect(to, headers);},
say: function(message) {that.say(callId, message);},
hangup: function() {that.hangup(callId);}, hangup: function() {that.hangup(callId);},
hold: function() {that.hold(callId);}, hold: function() {that.hold(callId);},
join: function() {that.join(mixer, headers);}, join: function() {that.join(mixer, headers);},
...@@ -498,7 +557,7 @@ Strophe.addConnectionPlugin('rayo', ...@@ -498,7 +557,7 @@ Strophe.addConnectionPlugin('rayo',
_handlePresence: function(presence) _handlePresence: function(presence)
{ {
//console.log('Rayo plugin handlePresence'); //console.log('Rayo plugin handlePresence');
//console.log(presence); console.log(presence);
var that = this; var that = this;
var from = $(presence).attr('from'); var from = $(presence).attr('from');
...@@ -516,11 +575,17 @@ Strophe.addConnectionPlugin('rayo', ...@@ -516,11 +575,17 @@ Strophe.addConnectionPlugin('rayo',
$(presence).find('complete').each(function() $(presence).find('complete').each(function()
{ {
$(this).find('success').each(function() $(this).find('success').each(function()
{ {
if ($(this).attr('xmlns') == Strophe.NS.RAYO_HANDSET_COMPLETE) if ($(this).attr('xmlns') == Strophe.NS.RAYO_HANDSET_COMPLETE)
{ {
that._onhook(); that._onhook();
} }
if ($(this).attr('xmlns') == Strophe.NS.RAYO_SAY_COMPLETE)
{
var sayId = Strophe.getResourceFromJid(from);
if (that.callbacks && that.callbacks.onSayComplete) that.callbacks.onSayComplete(sayId);
}
}); });
}); });
...@@ -536,7 +601,8 @@ Strophe.addConnectionPlugin('rayo', ...@@ -536,7 +601,8 @@ Strophe.addConnectionPlugin('rayo',
var call = { var call = {
digit: function(tone) {that.digit(callId, tone);}, digit: function(tone) {that.digit(callId, tone);},
redirect: function(to) {that.redirect(to, mixer, headers);}, redirect: function(to) {that.redirect(to, headers);},
say: function(message) {that.say(callId, message);},
hangup: function() {that.hangup(callId);}, hangup: function() {that.hangup(callId);},
hold: function() {that.hold(callId);}, hold: function() {that.hold(callId);},
answer: function() {that.answer(callId, mixer, headers, callFrom);}, answer: function() {that.answer(callId, mixer, headers, callFrom);},
...@@ -737,12 +803,13 @@ Strophe.addConnectionPlugin('rayo', ...@@ -737,12 +803,13 @@ Strophe.addConnectionPlugin('rayo',
var call = { var call = {
digit: function(tone) {that.digit(callId, tone);}, digit: function(tone) {that.digit(callId, tone);},
hangup: function() {that.hangup(callId);}, say: function(message) {that.say(callId, message);},
hold: function() {that.hold(callId);}, hangup: function() {that.hangup(callId);},
join: function() {that.join(mixer, headers);}, hold: function() {that.hold(callId);},
leave: function() {that.leave(mixer);}, join: function() {that.join(mixer, headers);},
mute: function(flag) {that.mute(callId, flag);}, leave: function() {that.leave(mixer);},
private: function() {that.private(callId, !this.privateCall);}, mute: function(flag) {that.mute(callId, flag);},
private: function() {that.private(callId, !this.privateCall);},
id: callId, id: callId,
from: Strophe.getNodeFromJid(jid), from: Strophe.getNodeFromJid(jid),
......
...@@ -50,8 +50,7 @@ public class TreatmentManager implements MixDataSource { ...@@ -50,8 +50,7 @@ public class TreatmentManager implements MixDataSource {
private static String[] soundPath; private static String[] soundPath;
static { static {
String s = System.getProperty("com.sun.voip.server.Bridge.soundPath", String s = System.getProperty("com.sun.voip.server.Bridge.soundPath", "/com/sun/voip/server/sounds");
"/com/sun/voip/server/sounds");
String[] sp = s.split(":"); String[] sp = s.split(":");
...@@ -124,6 +123,8 @@ public class TreatmentManager implements MixDataSource { ...@@ -124,6 +123,8 @@ public class TreatmentManager implements MixDataSource {
public void pause(boolean isPaused) { public void pause(boolean isPaused) {
this.isPaused = isPaused; this.isPaused = isPaused;
Logger.println("TreatmentManager paused " + isPaused);
} }
public boolean isPaused() { public boolean isPaused() {
...@@ -185,6 +186,11 @@ public class TreatmentManager implements MixDataSource { ...@@ -185,6 +186,11 @@ public class TreatmentManager implements MixDataSource {
} }
public int[] getLinearData(int sampleTime) { public int[] getLinearData(int sampleTime) {
if (isPaused) {
return null;
}
synchronized (treatments) { synchronized (treatments) {
audioSource = getAudioSource(); audioSource = getAudioSource();
......
...@@ -160,6 +160,8 @@ public class RayoComponent extends AbstractComponent ...@@ -160,6 +160,8 @@ public class RayoComponent extends AbstractComponent
@Override @Override
protected IQ handleIQGet(IQ iq) throws Exception { protected IQ handleIQGet(IQ iq) throws Exception {
Log.info("RayoComponent handleIQGet \n" + iq.toString());
final Element element = iq.getChildElement(); final Element element = iq.getChildElement();
final String namespace = element.getNamespaceURI(); final String namespace = element.getNamespaceURI();
...@@ -450,7 +452,7 @@ public class RayoComponent extends AbstractComponent ...@@ -450,7 +452,7 @@ public class RayoComponent extends AbstractComponent
childElement.addAttribute(LOCAL_PORT, Integer.toString(channel.getPortA())); childElement.addAttribute(LOCAL_PORT, Integer.toString(channel.getPortA()));
childElement.addAttribute(REMOTE_PORT, Integer.toString(channel.getPortB())); childElement.addAttribute(REMOTE_PORT, Integer.toString(channel.getPortB()));
childElement.addAttribute(ID, channel.getAttachment()); childElement.addAttribute(ID, channel.getAttachment());
childElement.addAttribute(URI, "handset:" + channel.getAttachment() + "@" + getDomain() + "/" + iq.getFrom().getNode()); childElement.addAttribute(URI, "xmpp:" + channel.getAttachment() + "@" + getDomain() + "/webrtc");
Log.debug("Created WebRTC handset channel {}:{}, {}:{}, {}:{}", new Object[]{HOST, LocalIPResolver.getLocalIP(), LOCAL_PORT, Integer.toString(channel.getPortA()), REMOTE_PORT, Integer.toString(channel.getPortB())}); Log.debug("Created WebRTC handset channel {}:{}, {}:{}, {}:{}", new Object[]{HOST, LocalIPResolver.getLocalIP(), LOCAL_PORT, Integer.toString(channel.getPortA()), REMOTE_PORT, Integer.toString(channel.getPortB())});
...@@ -465,7 +467,7 @@ public class RayoComponent extends AbstractComponent ...@@ -465,7 +467,7 @@ public class RayoComponent extends AbstractComponent
final Element childElement = reply.setChildElement("ref", RAYO_CORE); final Element childElement = reply.setChildElement("ref", RAYO_CORE);
childElement.addAttribute(ID, handsetId); childElement.addAttribute(ID, handsetId);
childElement.addAttribute(URI, "handset:" + handsetId + "@" + getDomain() + "/" + iq.getFrom().getNode()); childElement.addAttribute(URI, handset.sipuri);
Log.info("Created SIP handset channel " + handset.sipuri); Log.info("Created SIP handset channel " + handset.sipuri);
...@@ -578,10 +580,12 @@ public class RayoComponent extends AbstractComponent ...@@ -578,10 +580,12 @@ public class RayoComponent extends AbstractComponent
callHandler.playTreatmentToCall(treatmentId, this); callHandler.playTreatmentToCall(treatmentId, this);
final Element childElement = reply.setChildElement("ref", RAYO_CORE); final Element childElement = reply.setChildElement("ref", RAYO_CORE);
childElement.addAttribute(ID, treatmentId);
childElement.addAttribute(URI, (String) "xmpp:" + entityId + "@" + getDomain() + "/" + treatmentId); childElement.addAttribute(URI, (String) "xmpp:" + entityId + "@" + getDomain() + "/" + treatmentId);
} catch (Exception e1) { } catch (Exception e1) {
reply.setError(PacketError.Condition.internal_server_error); e1.printStackTrace();
reply.setError(PacketError.Condition.not_allowed);
} }
} catch (NoSuchElementException e) { // not call, lets try mixer } catch (NoSuchElementException e) { // not call, lets try mixer
...@@ -593,14 +597,15 @@ public class RayoComponent extends AbstractComponent ...@@ -593,14 +597,15 @@ public class RayoComponent extends AbstractComponent
conferenceManager.addTreatment(treatmentId); conferenceManager.addTreatment(treatmentId);
final Element childElement = reply.setChildElement("ref", RAYO_CORE); final Element childElement = reply.setChildElement("ref", RAYO_CORE);
childElement.addAttribute(ID, treatmentId);
childElement.addAttribute(URI, (String) "xmpp:" + entityId + "@" + getDomain() + "/" + treatmentId); childElement.addAttribute(URI, (String) "xmpp:" + entityId + "@" + getDomain() + "/" + treatmentId);
} catch (Exception e2) { } catch (Exception e2) {
reply.setError(PacketError.Condition.internal_server_error); e2.printStackTrace();
reply.setError(PacketError.Condition.not_allowed);
} }
} catch (ParseException e1) { } catch (ParseException e1) {
reply.setError(PacketError.Condition.item_not_found); reply.setError(PacketError.Condition.item_not_found);
} }
} }
...@@ -610,32 +615,37 @@ public class RayoComponent extends AbstractComponent ...@@ -610,32 +615,37 @@ public class RayoComponent extends AbstractComponent
private IQ handlePauseCommand(boolean flag, IQ iq) private IQ handlePauseCommand(boolean flag, IQ iq)
{ {
Log.info("RayoComponent handlePauseCommand " + iq.getFrom()); Log.info("RayoComponent handlePauseCommand " + iq.getFrom() + " " + iq.getTo());
IQ reply = IQ.createResultIQ(iq); IQ reply = IQ.createResultIQ(iq);
final String entityId = iq.getTo().getNode(); final JID entityId = getJID(iq.getTo().getNode());
final String treatmentId = iq.getTo().getResource();
try { if (entityId != null)
CallHandler callHandler = CallHandler.findCall(entityId); {
final String treatmentId = entityId.getResource();
final String callId = entityId.getNode();
try { CallHandler callHandler = CallHandler.findCall(callId);
callHandler.getMember().pauseTreatment(treatmentId, flag);
} catch (Exception e1) { if (callHandler != null)
reply.setError(PacketError.Condition.internal_server_error); {
} callHandler.getMember().pauseTreatment(treatmentId, flag);
} catch (NoSuchElementException e) { // not call, lets try mixer } else { // not call, lets try mixer
try { try {
ConferenceManager conferenceManager = ConferenceManager.findConferenceManager(entityId); ConferenceManager conferenceManager = ConferenceManager.findConferenceManager(callId);
conferenceManager.getWGManager().pauseConferenceTreatment(treatmentId, flag); conferenceManager.getWGManager().pauseConferenceTreatment(treatmentId, flag);
} catch (ParseException e1) { } catch (ParseException e1) {
reply.setError(PacketError.Condition.item_not_found); reply.setError(PacketError.Condition.item_not_found);
}
} }
} else {
reply.setError(PacketError.Condition.item_not_found);
} }
return reply; return reply;
...@@ -1208,9 +1218,11 @@ public class RayoComponent extends AbstractComponent ...@@ -1208,9 +1218,11 @@ public class RayoComponent extends AbstractComponent
sendPacket(presence); sendPacket(presence);
} else if ("230 TREATMENT DONE".equals(myEvent)) { } else if ("230 TREATMENT DONE".equals(myEvent)) {
//presence.getElement().add(rayoProvider.toXML(new DtmfEvent(callEvent.getCallId(), callEvent.getDtmfKey()))); presence.setFrom(callEvent.getCallId() + "@" + getDomain() + "/" + callEvent.getTreatmentId());
//sendPacket(presence); SayCompleteEvent complete = new SayCompleteEvent();
Log.info("230 TREATMENT DONE"); complete.setReason(SayCompleteEvent.Reason.valueOf("SUCCESS"));
presence.getElement().add(sayProvider.toXML(complete));
sendPacket(presence);
} }
} }
} }
......
...@@ -37,6 +37,8 @@ public class Application implements CallEventListener { ...@@ -37,6 +37,8 @@ public class Application implements CallEventListener {
config = Config.getInstance(); config = Config.getInstance();
config.initialise(); config.initialise();
String webHome = pluginDirectory.getAbsolutePath() + File.separator + ".." + File.separator + ".." + File.separator + "resources" + File.separator + "spank" + File.separator + "rayo";
System.setProperty("com.sun.voip.server.LOGLEVEL", "99"); System.setProperty("com.sun.voip.server.LOGLEVEL", "99");
System.setProperty("com.sun.voip.server.FIRST_RTP_PORT", "3200"); System.setProperty("com.sun.voip.server.FIRST_RTP_PORT", "3200");
System.setProperty("com.sun.voip.server.LAST_RTP_PORT", "3299"); System.setProperty("com.sun.voip.server.LAST_RTP_PORT", "3299");
...@@ -46,7 +48,8 @@ public class Application implements CallEventListener { ...@@ -46,7 +48,8 @@ public class Application implements CallEventListener {
System.setProperty("com.sun.voip.server.PUBLIC_IP_ADDRESS", config.getPublicHost()); System.setProperty("com.sun.voip.server.PUBLIC_IP_ADDRESS", config.getPublicHost());
System.setProperty("com.sun.voip.server.PROTOCOL", config.getDefaultProtocol()); System.setProperty("com.sun.voip.server.PROTOCOL", config.getDefaultProtocol());
System.setProperty("com.sun.voip.server.SIP_PORT", config.getDefaultSIPPort()); System.setProperty("com.sun.voip.server.SIP_PORT", config.getDefaultSIPPort());
System.setProperty("com.sun.voip.server.Bridge.recordDirectory", pluginDirectory.getAbsolutePath() + File.separator + ".." + File.separator + ".." + File.separator + "resources" + File.separator + "spank" + File.separator + "rayo" + File.separator + "recordings"); System.setProperty("com.sun.voip.server.Bridge.recordDirectory", webHome + File.separator + "recordings");
System.setProperty("com.sun.voip.server.Bridge.soundPath", "/com/sun/voip/server/sounds:" + webHome + File.separator + "sounds");
System.setProperty("freetts.voices", "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory"); System.setProperty("freetts.voices", "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory");
Properties properties = new Properties(); Properties properties = new Properties();
......
...@@ -63,7 +63,9 @@ Strophe.addConnectionPlugin('rayo', ...@@ -63,7 +63,9 @@ Strophe.addConnectionPlugin('rayo',
that._onhook(); that._onhook();
}, function(error) { }, function(error) {
that._onhook();
$('error', error).each(function() $('error', error).each(function()
{ {
var errorcode = $(this).attr('code'); var errorcode = $(this).attr('code');
...@@ -77,7 +79,7 @@ Strophe.addConnectionPlugin('rayo', ...@@ -77,7 +79,7 @@ Strophe.addConnectionPlugin('rayo',
//console.log("Rayo plugin digit " + callId + " " + key); //console.log("Rayo plugin digit " + callId + " " + key);
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 + "@" + this._connection.domain, from: this._connection.jid, type: "get"}).c("dtmf", {xmlns: Strophe.NS.RAYO_CORE, tones: key});
that._connection.sendIQ(iq, null, function(error) that._connection.sendIQ(iq, null, function(error)
{ {
...@@ -114,7 +116,7 @@ Strophe.addConnectionPlugin('rayo', ...@@ -114,7 +116,7 @@ Strophe.addConnectionPlugin('rayo',
//console.log("hold " + callId); //console.log("hold " + callId);
var that = this; var that = this;
var iq = $iq({to: callId + "@rayo." + this._connection.domain, from: this._connection.jid, type: "get"}).c("hold", {xmlns: Strophe.NS.RAYO_HANDSET}); var iq = $iq({to: callId + "@" + this._connection.domain, from: this._connection.jid, type: "get"}).c("hold", {xmlns: Strophe.NS.RAYO_HANDSET});
//console.log(iq.toString()); //console.log(iq.toString());
...@@ -133,12 +135,12 @@ Strophe.addConnectionPlugin('rayo', ...@@ -133,12 +135,12 @@ Strophe.addConnectionPlugin('rayo',
}); });
}, },
redirect: function(to, mixer, headers) redirect: function(to, headers)
{ {
//console.log("redirect " + to + " " + mixer); //console.log("redirect " + to);
var that = this; var that = this;
var iq = $iq({to: callId + "@rayo." + this._connection.domain, from: this._connection.jid, type: "get"}).c("redirect", {xmlns: Strophe.NS.RAYO_CORE, to: to}); var iq = $iq({to: this._connection.domain, from: this._connection.jid, type: "get"}).c("redirect", {xmlns: Strophe.NS.RAYO_CORE, to: to});
if (headers) if (headers)
{ {
...@@ -176,12 +178,68 @@ Strophe.addConnectionPlugin('rayo', ...@@ -176,12 +178,68 @@ Strophe.addConnectionPlugin('rayo',
}); });
}, },
say: function(callId, message)
{
//console.log('Rayo plugin say ' + callId + " " + message);
var that = this;
var iq = $iq({to: callId + "@" + this._connection.domain, from: this._connection.jid, type: "get"}).c( "say", {xmlns: Strophe.NS.RAYO_SAY}).t(message);
that._connection.sendIQ(iq, function(response)
{
$('ref', response).each(function()
{
var sayId = $(this).attr('id');
var node = Strophe.escapeNode(callId + "@" + that._connection.domain + "/" + sayId);
if (that.callbacks && that.callbacks.onSay) that.callbacks.onSay(
{
sayId: sayId,
pause: function()
{
that._connection.sendIQ($iq({to: node + "@" + that._connection.domain, from: that._connection.jid, type: "get"}).c( "pause", {xmlns: Strophe.NS.RAYO_SAY}), function(response){}, null, function(error){
$('error', error).each(function()
{
var errorcode = $(this).attr('code');
if (that.callbacks && that.callbacks.onError) that.callbacks.onError("pause failure " + errorcode);
});
});
},
resume: function()
{
that._connection.sendIQ($iq({to: node + "@" + that._connection.domain, from: that._connection.jid, type: "get"}).c( "resume", {xmlns: Strophe.NS.RAYO_SAY}), null, function(error){
$('error', error).each(function()
{
var errorcode = $(this).attr('code');
if (that.callbacks && that.callbacks.onError) that.callbacks.onError("resume failure " + errorcode);
});
});
}
});
});
}, function(error) {
$('error', error).each(function()
{
var errorcode = $(this).attr('code');
if (that.callbacks && that.callbacks.onError) that.callbacks.onError("say failure " + errorcode);
});
});
},
private: function(callId, flag) private: function(callId, flag)
{ {
//console.log('Rayo plugin private ' + callId + " " + flag); //console.log('Rayo plugin private ' + callId + " " + flag);
var that = this; var that = this;
var iq = $iq({to: callId + "@rayo." + this._connection.domain, from: this._connection.jid, type: "get"}).c( flag ? "private" : "public", {xmlns: Strophe.NS.RAYO_HANDSET}); var iq = $iq({to: callId + "@" + this._connection.domain, from: this._connection.jid, type: "get"}).c( flag ? "private" : "public", {xmlns: Strophe.NS.RAYO_HANDSET});
that._connection.sendIQ(iq, null, function(error) that._connection.sendIQ(iq, null, function(error)
{ {
...@@ -192,14 +250,14 @@ Strophe.addConnectionPlugin('rayo', ...@@ -192,14 +250,14 @@ Strophe.addConnectionPlugin('rayo',
}); });
}); });
}, },
mute: function(callId, flag) mute: function(callId, flag)
{ {
//console.log('Rayo plugin mute ' + callId + " " + flag); //console.log('Rayo plugin mute ' + callId + " " + flag);
var that = this; var that = this;
var iq = $iq({to: callId + "@rayo." + this._connection.domain, from: this._connection.jid, type: "get"}).c( flag ? "mute" : "unmute", {xmlns: Strophe.NS.RAYO_HANDSET}); var iq = $iq({to: callId + "@" + this._connection.domain, from: this._connection.jid, type: "get"}).c( flag ? "mute" : "unmute", {xmlns: Strophe.NS.RAYO_HANDSET});
that._connection.sendIQ(iq, null, function(error) that._connection.sendIQ(iq, null, function(error)
{ {
...@@ -227,7 +285,7 @@ Strophe.addConnectionPlugin('rayo', ...@@ -227,7 +285,7 @@ Strophe.addConnectionPlugin('rayo',
this._offhook(mixer, headers, function() this._offhook(mixer, headers, function()
{ {
var iq = $iq({to: callId + "@rayo." + that._connection.domain, from: that._connection.jid, type: "get"}).c("answer", {xmlns: Strophe.NS.RAYO_CORE}); var iq = $iq({to: callId + "@" + that._connection.domain, from: that._connection.jid, type: "get"}).c("answer", {xmlns: Strophe.NS.RAYO_CORE});
var hdrs = Object.getOwnPropertyNames(headers) var hdrs = Object.getOwnPropertyNames(headers)
...@@ -298,7 +356,8 @@ Strophe.addConnectionPlugin('rayo', ...@@ -298,7 +356,8 @@ Strophe.addConnectionPlugin('rayo',
that.callbacks.onAccept( that.callbacks.onAccept(
{ {
digit: function(tone) {that.digit(callId, tone);}, digit: function(tone) {that.digit(callId, tone);},
redirect: function(to) {that.redirect(to, mixer, headers);}, redirect: function(to) {that.redirect(to, headers);},
say: function(message) {that.say(callId, message);},
hangup: function() {that.hangup(callId);}, hangup: function() {that.hangup(callId);},
hold: function() {that.hold(callId);}, hold: function() {that.hold(callId);},
join: function() {that.join(mixer, headers);}, join: function() {that.join(mixer, headers);},
...@@ -498,7 +557,7 @@ Strophe.addConnectionPlugin('rayo', ...@@ -498,7 +557,7 @@ Strophe.addConnectionPlugin('rayo',
_handlePresence: function(presence) _handlePresence: function(presence)
{ {
//console.log('Rayo plugin handlePresence'); //console.log('Rayo plugin handlePresence');
//console.log(presence); console.log(presence);
var that = this; var that = this;
var from = $(presence).attr('from'); var from = $(presence).attr('from');
...@@ -516,11 +575,17 @@ Strophe.addConnectionPlugin('rayo', ...@@ -516,11 +575,17 @@ Strophe.addConnectionPlugin('rayo',
$(presence).find('complete').each(function() $(presence).find('complete').each(function()
{ {
$(this).find('success').each(function() $(this).find('success').each(function()
{ {
if ($(this).attr('xmlns') == Strophe.NS.RAYO_HANDSET_COMPLETE) if ($(this).attr('xmlns') == Strophe.NS.RAYO_HANDSET_COMPLETE)
{ {
that._onhook(); that._onhook();
} }
if ($(this).attr('xmlns') == Strophe.NS.RAYO_SAY_COMPLETE)
{
var sayId = Strophe.getResourceFromJid(from);
if (that.callbacks && that.callbacks.onSayComplete) that.callbacks.onSayComplete(sayId);
}
}); });
}); });
...@@ -536,7 +601,8 @@ Strophe.addConnectionPlugin('rayo', ...@@ -536,7 +601,8 @@ Strophe.addConnectionPlugin('rayo',
var call = { var call = {
digit: function(tone) {that.digit(callId, tone);}, digit: function(tone) {that.digit(callId, tone);},
redirect: function(to) {that.redirect(to, mixer, headers);}, redirect: function(to) {that.redirect(to, headers);},
say: function(message) {that.say(callId, message);},
hangup: function() {that.hangup(callId);}, hangup: function() {that.hangup(callId);},
hold: function() {that.hold(callId);}, hold: function() {that.hold(callId);},
answer: function() {that.answer(callId, mixer, headers, callFrom);}, answer: function() {that.answer(callId, mixer, headers, callFrom);},
...@@ -737,12 +803,13 @@ Strophe.addConnectionPlugin('rayo', ...@@ -737,12 +803,13 @@ Strophe.addConnectionPlugin('rayo',
var call = { var call = {
digit: function(tone) {that.digit(callId, tone);}, digit: function(tone) {that.digit(callId, tone);},
hangup: function() {that.hangup(callId);}, say: function(message) {that.say(callId, message);},
hold: function() {that.hold(callId);}, hangup: function() {that.hangup(callId);},
join: function() {that.join(mixer, headers);}, hold: function() {that.hold(callId);},
leave: function() {that.leave(mixer);}, join: function() {that.join(mixer, headers);},
mute: function(flag) {that.mute(callId, flag);}, leave: function() {that.leave(mixer);},
private: function() {that.private(callId, !this.privateCall);}, mute: function(flag) {that.mute(callId, flag);},
private: function() {that.private(callId, !this.privateCall);},
id: callId, id: callId,
from: Strophe.getNodeFromJid(jid), from: Strophe.getNodeFromJid(jid),
......
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