summaryrefslogtreecommitdiff
path: root/src/rooms.clj
diff options
context:
space:
mode:
authorsostler <sbostler@gmail.com>2010-05-27 20:24:39 -0400
committersostler <sbostler@gmail.com>2010-05-27 20:24:39 -0400
commitb5ecbae40ab352995df2461301d72067ae5ed397 (patch)
treed8fc0ba472c6236c9cf6fb7b891508b38e93c41f /src/rooms.clj
parent1f52229775ac654aaf4e1807b38a4bc1527a1434 (diff)
Fixed feed msg insertion transaction
Diffstat (limited to 'src/rooms.clj')
-rw-r--r--src/rooms.clj9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/rooms.clj b/src/rooms.clj
index e18a434..09b81ba 100644
--- a/src/rooms.clj
+++ b/src/rooms.clj
@@ -1,7 +1,10 @@
(ns rooms
+ (:import java.util.Date)
(:use clojure.contrib.str-utils
utils))
+(defstruct message-struct :nick :content :created_on :msg_id)
+
(def *run-flusher* true)
(def *flusher-sleep* (seconds 4))
(def *user-timeout* (seconds 15))
@@ -81,6 +84,12 @@
(defn login-user [user room]
(alter (room :users) assoc (user :nick) user))
+; Note: To ensure that the msg's timestamp is consistent
+; with other msg creations, build-msg should be called
+; from within a dosync.
+(defn build-msg [nick content msg-id]
+ (struct message-struct nick content (new Date) msg-id))
+
(defn add-message [msg room]
(alter (room :messages) (swap cons) msg))