Skip to content

Commit

Permalink
Updated README
Browse files Browse the repository at this point in the history
  • Loading branch information
John Roy authored and John Roy committed Jun 10, 2014
1 parent 4383d92 commit a78b814
Showing 1 changed file with 43 additions and 108 deletions.
151 changes: 43 additions & 108 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,129 +1,64 @@
**NOTE**
========
Code is currently being refactored. Do not use. Preliminary.

Description
===========
Phonegap (Cordova) plugin to wrap the linphone library softphone library for phonegap videophone applications.


Important
=========
In order to use this plugin you will need to download and build the linphone iOS libraries and then add them to your phonegap project. This is a challenging task. Start at linphone.org


Simple Usage
=====

```javascript

Description
===========
Wraps linphone library functions to allow adding videophone features to a phonegap (cordova) app
window.plugins.LinPhoneGap.call("+16505551212",function(err){});

```

Usage
=====

```javascript

...Error return by the plugin : ["feature","empty"] ???

var inCall = false, pin = null, firsttime = true;
function onCallUpdate(dict) {
document.getElementById('call').disabled = (dict.canCall!==true);
document.getElementById('hangup').disabled = (dict.canHangup!==true);
document.getElementById('videoOn').disabled = (dict.canStartVideo!==true);
document.getElementById('videoOff').disabled = (dict.canStopVideo!==true);
inCall = (dict.canCall!==true);
}




function ready() {
// doesn't seem this is ever called
// window.plugins.BRSIP.fubar(function(msg){alert(msg?msg:"OK");});
// window.plugins.BRSIP.fubar(foo2,foo2);
//foo2({_state:"foo"});
console.log=window.plugins.BRSIP.log;
window.plugins.BRSIP.log("foo");
window.plugins.BRSIP.initPhone(onCallUpdate);
window.BR.api.v1.init(init_arg);
// window.BR.api.v1.currentUser(function(e,d){
/*
window.BR.api.v1.addSelf('/john',{name:"Luloo"},function(e,d){
console.log(e||JSON.stringify(d));
});
*/
document.getElementById('enter').disabled = false;
}
function doLogin(name) {
window.BR.api.v1.addSelf(room,{name:name},function(e,d){ /* addSelf so cookie gets set */
if (!e && d.user && d.user.id /* d.user.name also exists FYI */) {
document.getElementById('enter').innerHTML = "Please wait...";
setTimeout(checkInvitation,0); // bit of a hack, change so SIP connections auto-retry on server...
}
// console.log(e||JSON.stringify(d));
});
}
function checkInvitation(callToLogin) {
window.BR.api.v1.invitation(room,function(e,d){
console.log(e||JSON.stringify(d));
if (!e && d) {
if (d.pin) {
pin = d.pin;
document.getElementById('enter').disabled = false;
document.getElementById('text').disabled = true;
document.getElementById('enter').innerHTML = "Enter Room";
doEnterRoom();
}
else if (d.pin===null && callToLogin)
callToLogin();
else
document.getElementById('enter').disabled = false;
}
else
document.getElementById('enter').disabled = false;
});
}
function goBack() {
//window.location.href = "room.html";
if (inCall)
window.plugins.BRSIP.hangup();
document.getElementById('roomiframe').src = "https://babelroom.com/"; // seems this is the only way to close webview room, i.e. point to a new VALID url
document.body.style['background-color'] = '#5678a7';
document.getElementById('home').style.visibility = 'visible';
document.getElementById('room').style.visibility = 'hidden';
}
function enterRoom() {
document.getElementById('enter').disabled = true;
checkInvitation(function(){doLogin(document.getElementById('text').value);});
}
function doEnterRoom() {
if (firsttime) {
doCall();
firsttime = false;
}
document.getElementById('roomiframe').src = url+room;
// document.body.style['background-color'] = '#000000';
document.body.style['background-color'] = 'transparent';
document.getElementById('home').style.visibility = 'hidden';
document.getElementById('room').style.visibility = 'visible';
}
// function fubar(p) {
// window.plugins.BRSIP.echo(p,function(msg){alert(msg?msg:"OK");});
// }
function doCall() {
//console.log("pin="+pin);
window.plugins.BRSIP.call(pin,addr,function(err){/*alert('OK')*/;});
}
function doHangup() {
window.plugins.BRSIP.hangup(function(err){/*alert('OK')*/;});
}
function doVideoOn() { window.plugins.BRSIP.videoOn(function(err){;}); }
function doVideoOff() { window.plugins.BRSIP.videoOff(function(err){;}); }
// function jrtest(str){
// //alert(str);
// foo2(str);
// }
</script>
...

<div>
<input type="text" id="number" value="Guest" />
<button id="call" onClick="javascript:doCall();" disabled>Call</button>
<button id="hangup" onClick="javascript:doHangup();" disabled>Hangup</button>
<button id="videoOn" onClick="javascript:doVideoOn();" disabled>Video On</button>
<button id="videoOff" onClick="javascript:doVideoOff();" disabled>Video Off</button>
</div>

<script>
var inCall = false;
function onCallUpdate(dict) {
document.getElementById('call').disabled = (dict.canCall!==true);
document.getElementById('hangup').disabled = (dict.canHangup!==true);
document.getElementById('videoOn').disabled = (dict.canStartVideo!==true);
document.getElementById('videoOff').disabled = (dict.canStopVideo!==true);
inCall = (dict.canCall!==true);
}

function doCall() {
var number = document.getElementById('number').value;
window.plugins.LinPhoneGap.call(number,function(err){});
}

function doHangup() { window.plugins.LinPhoneGap.hangup(function(err){}); }
function doVideoOn() { window.plugins.LinPhoneGap.videoOn(function(err){}); }
function doVideoOff() { window.plugins.LinPhoneGap.videoOff(function(err){}); }
</script>

...


```

Installation
============
cordova local plugin add "current repo"
cordova local plugin add LinPhoneGap

0 comments on commit a78b814

Please sign in to comment.