Tinyphone web client

Tinyphone apps can be built in Javascript using the Tinyphone web client.  The web client makes it possible to handle phone call events inside a browser.

The easiest way to install the web client is to clone the project from Github.

git clone git://github.com/itp-redial/tinyphone-webclient

The Github repo contains the client, called “tinyphone_client.js“, and some example web pages.

The tinyphone client is expecting to connect to the tinyphone server.  Make sure that you have installed Asterisk and the Tinyphone Server.

One of the examples, “tinyphone_simple.html“, is posted below. Tinyphone_simple.html is a good template for your projects. As you can see, there’s 3 basic steps to configuring a tinyphone app.

  1. Include tinyphone_client.js in your html page.
  2. Initialize tinyphone client with the tinyphone server with server location, port, and phone number that people will call.
  3. register listeners for the 4 tinyphone events: new_call, keypress, audio_level, and hangup.  All listeners are optional.  For example, if you don’t care about audio level events, you can leave out that listener.
<html>
<body>
<script type="text/javascript" src="tinyphone_client.js"></script>
<script>
var phoneNumber = "13605162008";
var cr = "<br/>"; //add a line break to each addition to page.
tinyphone.init("108.171.177.45",12003,phoneNumber);
tinyphone.on('connect', function(){
document.write("connected to tinyphone with phone number "+tinyphone.phoneNumber+cr);
});
tinyphone.on('new_call', function(caller){
document.write("new caller "+caller.callerNumber+", id "+caller.id+cr);
});
tinyphone.on('keypress', function(caller){
document.write("received keypress '"+caller.keypress+"' from "+caller.callerNumber+cr);
});
tinyphone.on('audio_level', function(caller){
document.write("received audio level '"+caller.audioLevel+"' from "+caller.callerNumber);
});
tinyphone.on('hangup', function(caller){
document.write("caller "+caller.callerNumber+"( id "+caller.id+") hung up"+cr);
});
</script>
</body>
</html>

All other examples included with tinyphone_client.js are expansions on the simple template.