Introduction

Sipatra is a simple Sinatra.rb like Ruby DSL for SIP Servlets. It's heavily inspired from Sinatra.rb and was adapted only in those areas that were required by differences between the HTTP and SIP protocols. Sipatra is written is JRuby and targets SIP Servlet 1.1 compatible application servers.

Sipatra is a work in progress. Until we reach version 1.0 the Ruby DSL may change without notice.

The main goals of Sipatra project are:

Ressources

Quick overview: introducing Handler with Sipatra

In Sipatra an handler is a ruby block which is called to handle a SIP message when a set of conditions are satisfied. Those conditions are selectors which must match the message's SIP method, URI or headers.

invite 'sip:standard@.*' do
    proxy "sip:0123456789@#{message.uri.host}"
    puts "VIA    : '#{headers[:Via].join(", ")}'"
    puts "CONTACT: '#{header['Contact']}'"
    send_response 200, "OK", 'X-Header' => 'Foo'
end

register do
    proxy
end

Those handlers have to be put in a file called WEB-INF/jruby/application.rb and you need to add the following declaration to your WEB-INF/sip.xml. DSL methods exist for the following SIP methods: ACK, BYE, CANCEL, INFO, INVITE, MESSAGE, NOTIFY, OPTIONS, PRACK, PUBLISH, REFER, REGISTER, SUBSCRIBE, UPDATE (http://en.wikipedia.org/wiki/List_of_SIP_request_methods).

To use Sipatra in your SIP applications, just add the following declaration to you WEB-INF/sip.xml file together with the dependencies listed below.

  <servlet>
      <servlet-name>jruby</servlet-name>
      <servlet-class>org.cipango.jruby.JRubyServlet</servlet-class>
      <load-on-startup/>
  </servlet>