connection.clj
Branches > facts > 1e3557f > files / src / net / bowmap / network / connection.clj
(ns net.bowmap.network.connection
(:require
[clojure.core.async :refer [chan]]
[net.bowmap.network.streams :as streams])
(:import
[java.net Socket]))
; Connection can be sent and received frames?
; It is the I/O part of the client
; Clients are then I/O free
; TODO I really don't like any of this lol
(defn connection [socket]
{::socket socket
::input-stream (Socket/.getInputStream socket)
::output-stream (Socket/.getOutputStream socket)
::serverbound-frames (chan 64)})
(defn read-frame!! [connection]
(streams/read-frame!! (req! connection ::input-stream)))
(defn send-frame!! [frame connection]
(streams/write-frame!! frame (req! connection ::output-stream)))
(defn close! [connection]
(Socket/.close (::socket connection)))