 
 ; Writing Packets ------------------------------------------------------------------
 (defn write-packet-keepalive [conn _]
-      (writ-byte conn (:handshake packet-ids)))
+      (-write-byte conn (:handshake packet-ids)))
 
 (defn write-packet-handshake [conn {username :username}]
-      (writ-byte conn (:handshake packet-ids))
+      (-write-byte conn (:handshake packet-ids))
 
-      (writ-string16 conn username))
+      (-write-string16 conn username))
 
 (defn write-packet-login [conn {version :version, username :username}]
-      (writ-byte conn (:login packet-ids))
+      (-write-byte conn (:login packet-ids))
 
-      (writ-int conn version)
-      (writ-string16 conn username)
-      (writ-long conn 0)
-      (writ-byte conn 0))
+      (-write-int conn version)
+      (-write-string16 conn username)
+      (-write-long conn 0)
+      (-write-byte conn 0))
+
+(defn write-packet-chat [conn {message :message}]
+      (-write-byte conn (:chat packet-ids))
+
+      (-write-string16 conn message))
 
 
 ; Writing Wrappers -----------------------------------------------------------------

            (= packet-type :keepalive) (read-packet-keepalive conn)
            (= packet-type :handshake) (read-packet-handshake conn)
            (= packet-type :login) (read-packet-login conn)
            :else (str "UNKNOWN PACKET TYPE: " packet-id)
            ))
        (println "\n\n\n")))



; Reading Data ---------------------------------------------------------------------
(defn -read-byte [conn]
   (let [b (.readByte (:in @conn))]
     b))

(defn -read-int [conn]
   (let [i (.readInt (:in @conn))]
     i))

(defn -read-long [conn]
   (let [i (.readLong (:in @conn))]
     i))

(defn -read-string16 [conn]
  (let [str-len (.readShort (:in @conn))
        s (apply str (repeatedly str-len #(.readChar (:in @conn))))]
    s))
