-
-
Save bjering/9af1d5dc17539d94cc77 to your computer and use it in GitHub Desktop.
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 chat.common) | |
(defn send-message | |
[agt message-name & args] | |
;(println "Sending " message-name " to " agt " with args = " args) | |
(send agt #(apply (% message-name) % args))) | |
; I realize this are two unsyncronized agents and | |
; for a short while it could be that a user | |
; is added to the channel, but not the channel | |
; to the user, and vice versa. | |
; This is ok! | |
(defn add-user-to-channel | |
[user channel] | |
(user :send :add-channel channel) | |
(channel :send :add-user user)) | |
(defn login | |
[session user] | |
(session :send :set-user user) | |
(user :send :set-session session) | |
nil) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment