19fc4b6444f5
Buffer input and output.
author | Steve Losh <steve@stevelosh.com> |
---|---|
date | Wed, 31 Aug 2011 18:50:12 -0400 |
parents | aa67f93d6fe4 |
children | 674073671e6c |
branches/tags | (none) |
files | src/clojurecraft/core.clj |
Changes
--- a/src/clojurecraft/core.clj Fri Aug 26 20:12:29 2011 -0400 +++ b/src/clojurecraft/core.clj Wed Aug 31 18:50:12 2011 -0400 @@ -10,7 +10,7 @@ (:require (clojurecraft.data)) (:import [clojurecraft.data Location Entity Block Chunk World Bot]) (:import (java.net Socket) - (java.io DataOutputStream DataInputStream) + (java.io DataOutputStream DataInputStream BufferedInputStream BufferedOutputStream) (java.util.concurrent LinkedBlockingQueue TimeUnit))) (def STARTING-LOC (Location. 0 0 0 0 0 0 false)) @@ -108,8 +108,8 @@ (defn connect [server username] (let [username (or username (random-username)) socket (Socket. (:name server) (:port server)) - in (DataInputStream. (.getInputStream socket)) - out (DataOutputStream. (.getOutputStream socket)) + in (DataInputStream. (BufferedInputStream. (.getInputStream socket))) + out (DataOutputStream. (BufferedOutputStream. (.getOutputStream socket))) conn (ref {:in in :out out}) outqueue ^LinkedBlockingQueue (LinkedBlockingQueue.) actionqueue (LinkedBlockingQueue.)