Skip to content

Instantly share code, notes, and snippets.

@bjering
Created August 23, 2010 13:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bjering/9af1d5dc17539d94cc77 to your computer and use it in GitHub Desktop.
Save bjering/9af1d5dc17539d94cc77 to your computer and use it in GitHub Desktop.
(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