Skip to content

Commit

Permalink
move playground to ./dev
Browse files Browse the repository at this point in the history
  • Loading branch information
mpenet committed Oct 11, 2023
1 parent 832ed0f commit e56fa8c
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions dev/playground.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
(ns dev.playground
(:require
[gniazdo.core :as ws]
[s-exp.mina :as m]
[s-exp.mina.websocket :as mws]))

(def r {:status 200})
(def h (fn [req] r))

(def s (m/start!
{:host "0.0.0.0" :port 8080
:http-hander #'h
:websocket-endpoints {"/foo"
{;; :subprotocols ["chat"]
:error (fn [session e]
(prn :err e))
:open (fn [session]
;; (prn :open)
)
:close (fn [session status data]
(prn :close status))
:message (fn [session data last]
(prn :message data last)
(mws/send! session data true))}}
:write-queue-length 10240
:connection-options {:socket-send-buffer-size 1024}}))

(def socket
(ws/connect
"ws://localhost:8080/foo"
:on-receive #(prn 'received %)
;; :headers {"foo" "bar"}
;; :subprotocols ["chat, foo"]
))
(ws/send-msg socket "hello")

(ws/close socket)

0 comments on commit e56fa8c

Please sign in to comment.