Created
June 22, 2015 10:19
-
-
Save akatov/156f980e633d3bfe2631 to your computer and use it in GitHub Desktop.
openymsg test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defproject msngr "0.1.0-SNAPSHOT" | |
:description "FIXME: write description" | |
:url "http://example.com/FIXME" | |
:license {:name "Eclipse Public License" | |
:url "http://www.eclipse.org/legal/epl-v10.html"} | |
:dependencies [[org.clojure/clojure "1.6.0"] | |
[net.sf.openymsg/openymsg "0.6.0"]] | |
:main msngr.core | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns msngr.core | |
(:import org.openymsg.network.LoginRefusedException | |
org.openymsg.network.ServiceType | |
org.openymsg.network.Session | |
org.openymsg.network.SessionState | |
org.openymsg.network.YahooException | |
org.openymsg.network.event.WaitListener | |
)) | |
(def users | |
[{:username "user1" | |
:password "password1"} | |
{:username "user2" | |
:password "password2"}]) | |
(defn login-user | |
"(login 0) => Session; or (login 1) => Session" | |
[user_index] | |
(let [session (Session.) | |
user (users user_index)] | |
(.login session (:username user) (:password user)) | |
session | |
)) | |
(defn listen [session] | |
) | |
(defn -main [] | |
(let [session0 (login-user 0) | |
;; session1 (login-user 1) | |
message0 "ohai Mark" | |
message1 "ohai Johnny"] | |
(println session0) | |
;; (println session1) | |
(Thread/sleep 1000) | |
(.sendMessage session0 (:username (users 1)) message0) | |
;; (.sendMessage session1 (:username (users 0)) message1) | |
(println "messages sent") | |
(Thread/sleep 1000) | |
(.logout session0) | |
;; (.logout session1) | |
(println "logged out") | |
)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment