~pepe/neil

72cd7e6359636940d1b8d3c22c33f47f6503b500 — Josef Pospíšil a month ago dcce799
Return give-supervisor, clean up uses
3 files changed, 8 insertions(+), 9 deletions(-)

M neil/sock/acts.janet
M neil/sock/init.janet
M neil/watch/init.janet
M neil/sock/acts.janet => neil/sock/acts.janet +1 -1
@@ 301,7 301,7 @@
    "actions"))

(define-watch Open [_ {:trevor t :env env :brush b} _]
  (give (start t env b add-one remove-one actions)))
  (give (start-chidi t env b add-one remove-one actions)))

(define-watch Init [_ {:hemple h :brush b :env env} _]
  (cond-> @[Open (log (. "Trevor Present on " (h env)))]

M neil/sock/init.janet => neil/sock/init.janet +6 -7
@@ 1,5 1,4 @@
(import chidi)
(import chidi/response)
(use chidi)
(import trevor)
(import json)
(import shawn/cocoon)


@@ 33,12 32,12 @@
            (put self :expiration expiration)
            (do
              (:write connection
                      (response/not-authorized "Provided session key does not exist"))
                      (not-authorized "Provided session key does not exist"))
              (cocoon/emerge (log "Socket is not authorized"))))
          fine)
        (do
          (:write connection
                  (response/not-authorized "You did not provide session key"))
                  (not-authorized "You did not provide session key"))
          (cocoon/emerge (log "Socket is not authorized"))
          false)))
    :read


@@ 65,11 64,11 @@
                        "Connection reset by peer"
                        "stream is closed")
          (protect (:write conn (trevor/text (json/encode {:error err}))))
          (ev/give chan [:close conn])))
          (ev/give-supervisor :close conn)))
      [:close connection] (:close connection))))

(defn start [t env brush add remove actions]
  (chidi/start
(defn start-chidi [t env brush add remove actions]
  (start
    (handler {:brush brush
              :add add
              :remove remove

M neil/watch/init.janet => neil/watch/init.janet +1 -1
@@ 81,7 81,7 @@
                           (internal-server-error
                             (. "Internal Server Error: " err)))))
        (emerge (log "watch close " ((string/split " " (describe conn)) 1)))
        (ev/give [:close conn]))
        (ev/give-supervisor :close conn))
      [:close conn] (:close conn))))

(defn start-chidi [c t env k b]