|
BigScreens / Asterisk
Asterisk and MPEThe full tutorial for Asterisk and Processing is available here: http://www.shiffman.net/p5/asterisk However, there a few things specific to our class and itp's server. Working on the serverFirst of all, the server is: asterisk.itp.tsoa.nyu.edu To use the server, you'll need to get an account. E-mail me with your netid if you want an account. Once you have an account, you'll need to login into the server by ssh'ing into it: ssh netid@asterisk.itp.tsoa.nyu.edu On the server, you'll have several folders: /asterisk_conf/ --> this is where you configure your NETID_extensions.conf file I also suggest that you create a "java" folder and put all of your classes in there (with the server files in a server folder) To compile on the server, you need to reference the path to java. /usr/java/jdk1.5.0_10/bin/javac server/JEAGIServer.java To run the server: /usr/java/jdk1.5.0_10/bin/java server.JEAGIServer To run the server in the background (so you can quit terminal, but have it continue to work): nohup /usr/java/jdk1.5.0_10/bin/java server.JEAGIServer & Then to quit the server later, you must find the process id: ps -ef | grep java and kill it: kill ##### SoftphoneTo test, you'll want to use a softphone (calling from your cell over and over is a pain). I use <a href="http://www.gizmoproject.com/">Gizmo</a>. Download and install Gizmo and configure it to use Asterisk. You'll need to make a file called netid_sip.conf and put that in your asterisk_conf folder. That file should look like this: [dts204_gizmo] type=friend username=netid_gizmo secret=netid_gizmo host=dynamic dtmfmode=rfc2833 allowguest=yes insecure=very promiscredir=yes context=dts204_default Your secret password is not secure so don't use anything private! Then, set up Gizmo to login into a "secondary" account. Server: asterisk.itp.tsoa.nyu.edu Account: netid_gizmo password: netid_gizmoe More info on soft phones from shawn's page: https://www.itp.nyu.edu/~sve204/redial_fall07/week3.html Using this with MPETwo main issues: 1. Processing's Client class has the same name as my MPE Client class. Oooops!!! To get around this, you have to refer to them by their full path: processing.net.Client netClient; mpe.client.Client client; netClient = new processing.net.Client(this,"asterisk.itp.tsoa.nyu.edu", 9001); 2. When you read the info in, you've got to broadcast it right back out! // If there is information available to read from the Server
if (ID == 0 && netClient.available() > 0) {
String msg = netClient.readString(); // Read it as a String
client.broadcast(msg);
}
You should only have one client get the phone call! Then you can do the parsing in frameEvent()
public void frameEvent(mpe.client.Client c){
if (c.messageAvailable()) {
String[] msg = c.getDataMessage();
String[] tokens = msg[0].trim().split(",");
if (tokens.length > 1) {
if (!calls.containsKey(tokens[0])) {
Call call = new Call(this,client,tokens[0],random(width),random(height));
calls.put(call.id,call);
}
else if (tokens[1].equals("hangup")) {
calls.remove(tokens[0]);
}
else {
Call call = (Call) calls.get(tokens[0]);
if (call != null) {
call.command(tokens[1]);
}
}
}
}
redraw();
}
The example is on the CVS: /home/dts204/bigscreens/examples/Asterisk |