connection.clj
Branches > main > 5534b1b > files / src / net / bowmap / network / connection.clj
(ns net.bowmap.network.connection
(:require
[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]
(agent {::socket socket
::input-stream (Socket/.getInputStream socket)
::output-stream (Socket/.getOutputStream socket)}))
(defn send-frame-action! [connection frame]
(let [{:keys! [::output-stream]} connection]
(streams/write-frame!! frame output-stream)
connection))
(defn close! [connection]
(Socket/.close (req! connection ::socket)))