Skip to content

Commit

Permalink
0.6.0Alpha ready
Browse files Browse the repository at this point in the history
  • Loading branch information
Ruiyun committed May 14, 2013
1 parent f44ad4a commit 60456ce
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 15 deletions.
14 changes: 7 additions & 7 deletions README.md
Expand Up @@ -9,7 +9,7 @@ Installation

Add the following to your **project.clj** :

[cljain "0.5.0-RC2"]
[cljain "0.6.0-Alpha1"]

Then execute

Expand All @@ -22,19 +22,19 @@ And here is an example to show how to work with cljain.
(require '[cljain.sip.core :as sip]
'[cljain.sip.address :as addr])

(defmethod handle-request :MESSAGE [request transcation _]
(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")
(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.")))
:on-timeout (fn [& _] (println "Timeout, try it later.")))
```

Documentation
Expand All @@ -49,6 +49,6 @@ Copyright (C) 2013 Ruiyun Wen

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

[JAIN-SIP]: http://hudson.jboss.org/hudson/job/jain-sip/lastSuccessfulBuild/artifact/javadoc/index.html
[Clojure]:http://clojure.org/
[documentation]: http://ruiyun.github.io/cljain/
[JAIN-SIP]: http://hudson.jboss.org/hudson/job/jain-sip/lastSuccessfulBuild/artifact/javadoc/index.html
[Clojure]: http://clojure.org/
[documentation]: http://ruiyun.github.io/cljain/
2 changes: 1 addition & 1 deletion project.clj
@@ -1,4 +1,4 @@
(defproject cljain "0.6.0-SNAPSHOT"
(defproject cljain "0.6.0-Alpha1"
:description "Enjoy JAIN-SIP in Clojure's way."
:dependencies [[org.clojure/tools.logging "0.2.6"]
[ruiyun/tools.timer "1.0.1"]
Expand Down
2 changes: 1 addition & 1 deletion src/cljain/dum.clj
Expand Up @@ -8,7 +8,7 @@
(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\")
(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!)
Expand Down
8 changes: 3 additions & 5 deletions src/cljain/sip/address.clj
Expand Up @@ -33,11 +33,9 @@
(defn address
"Create a new Address object using a URI.
It useful to create the To header etc."
([^URI uri]
{:post [(instance? Address %)]}
(.createAddress factory uri))
([^URI uri display-name]
{:post [(instance? Address %)]}
([^String address]
(.createAddress factory address))
([^URI uri, display-name]
(.createAddress factory display-name uri)))

(defn sip-address
Expand Down
2 changes: 1 addition & 1 deletion src/cljain/sip/message.clj
Expand Up @@ -18,7 +18,7 @@
[method req-uri from call-id & more-headers]
(let [headers (apply hash-map (mapcat #(vector (.getName ^Header %) %) (remove nil? (flatten more-headers))))
cseq (get headers "CSeq" (header/cseq 1 method))
to (get headers "To" (header/to (addr/address req-uri) nil))
to (get headers "To" (header/to (addr/address req-uri nil) nil))
via (remove nil? [(get headers "Via")])
max-forward (get headers "Max-Forwards" (header/max-forwards 70))
request (.createRequest factory req-uri method call-id cseq from to via max-forward)
Expand Down

0 comments on commit 60456ce

Please sign in to comment.