Skip to content

Ruiyun/cljain

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

63 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cljain

The cljain is an abstraction layer sitting on top of JAIN-SIP. It let's you use it in Clojure's way.

Installation

Add the following to your project.clj :

[cljain "0.6.0-Alpha1"]

Then execute

lein deps

And here is an example to show how to work with cljain.

(use 'cljain.dum)
(require '[cljain.sip.core :as sip]
  '[cljain.sip.address :as addr])

(defmethod handle-request :MESSAGE [request transaction _]
  (println "Received: " (.getContent request))
  (send-response! 200 :in transaction :pack "I receive the message from myself."))

(global-set-account {:user "bob", :domain "localhost", :display-name "Bob", :password "thepwd"})
(sip/global-bind-sip-provider! (sip/sip-provider! "my-app" "localhost" 5060 "udp"))
(sip/set-listener! (dum-listener))
(sip/start!)

(send-request! :MESSAGE :to (addr/address "sip:bob@localhost") :pack "Hello, Bob."
  :on-success (fn [& {:keys [response]}] (println "Fine! response: " (.getContent response)))
  :on-failure (fn [& {:keys [response]}] (println "Oops!" (.getStatusCode response)))
  :on-timeout (fn [& _] (println "Timeout, try it later.")))

You can find more examples in the test directory.

Documentation

For more detailed information on cljain, please refer to the documentation.

License

Copyright (C) 2013 Ruiyun Wen

Distributed under the Eclipse Public License, the same as Clojure.

About

Use JAIN-SIP in Clojure way.

Resources

Stars

Watchers

Forks

Packages

No packages published