Introducing Moho Framework

I have blogged quite a bit about developing VoIP applications using SIP Servlet and Java Media Control APIs on top of Voxeo PRISM. Both are great standards by the Java community for call controls and media controls. But I have to admit that using these two APIs is not easy. Developers have to not only understand underlying protocols but also deal with the complexity of asynchronous event driven programing. Even worse, since SIP Servlet and Java Media Control are independent APIs, developers have to deal with different event models and uncorrelated state machines.

Given all the complexities of using SIP Servlet and Java Media Control APIs, I am quite excited about the Moho framework we are developing on top of SIP Servlet and Java Media Control APIs. It offers the best of both world. First, you have one much-easy-to-use and unified API for both call control and media control. Second, Moho framework is open source and sits on top of standard SIP Servlet and Java Media Control APIs so you don’t have to worry about vendor lock-in.

Before I get into details about Moho, let me show you a simple example to see how much work can be reduced by using Moho. Here I want to develop a simple IVR application which accepts every call and announces “Hello World” to the caller every 5 seconds.

To write this using SIP Servlet and Java Media Control, here is the HelloWorldServlet.java, which has about 200 lines of Java code.

On the other hand, a HellowWorld Moho application that provides the same functionality only has about 25 lines of Java code.

package com.voxeo.moho.tutorial.one;

import com.voxeo.moho.Application;
import com.voxeo.moho.ApplicationContext;
import com.voxeo.moho.Call;
import com.voxeo.moho.State;

public class HelloWorld implements Application {
  public void init(ApplicationContext context) {
  }

  public void destroy() {
  }

  @State
  public void onCall(Call call) {
    call.answer();
    while (call.getCallState() == Call.State.CONNECTED) {
      try {
        call.getMediaService().output("Hello World!").get();
        Thread.sleep(5000);
      }
      catch (Exception e) {
      }
    }
  }
}

Even with far less lines of code, this Moho application actually handles more functions, such as SIP reInvite, SIP Cancel, etc.

To run this HelloWorld Moho application, simply download and deploy the WAR to <prism>/apps directory, assuming you have Voxeo PRISM already installed.

You may also run this application on any other JSR 289 and JSR 309 compliant servers. Since other servers probably don’t have Moho dependencies embedded, you have to add all the Moho runtime dependencies to WAR. Moho runtime dependencies can be downloaded from Moho Downloads.

Related posts:

  1. Introducing GWOB Marketplace
  2. Introducing AhnHub.com – The Adhearsion Component Directory

One thought on “Introducing Moho Framework

  1. Everyone seems to be going video: from websites (Google+, Facebook, etc.) to SIP clients (Jitsi, Ekiga, Bria, EyeBeam, etc.). Does Moho support video?

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>