-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
83 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
(ns s-exp.mina.websocket.response | ||
(:import (io.helidon.common.buffers BufferData) | ||
(io.helidon.websocket WsSession))) | ||
|
||
(set! *warn-on-reflection* true) | ||
|
||
(defprotocol ToBufferData | ||
(buffer-data [x])) | ||
|
||
(extend-protocol ToBufferData | ||
|
||
(Class/forName "[B") | ||
(buffer-data [ba] | ||
(BufferData/create ^"[B" ba)) | ||
|
||
String | ||
(buffer-data [s] | ||
(BufferData/create s)) | ||
|
||
clojure.lang.Sequential | ||
(buffer-data [s] | ||
(BufferData/create s)) | ||
|
||
BufferData | ||
(buffer-data [bd] | ||
bd) | ||
|
||
nil | ||
(buffer-data [x] | ||
(BufferData/empty))) | ||
|
||
(defn send! | ||
[^WsSession ws-session data last] | ||
(.send ws-session (buffer-data data) | ||
(boolean last))) | ||
|
||
(defn ping! | ||
[^WsSession ws-session data] | ||
(.ping ws-session (buffer-data data))) | ||
|
||
(defn pong! | ||
[^WsSession ws-session data] | ||
(.pong ws-session (buffer-data data))) | ||
|
||
(defn close! | ||
[^WsSession ws-session code reason] | ||
(.close ws-session (int code) (str reason))) | ||
|
||
(defn terminate! | ||
[^WsSession ws-session] | ||
(.terminate ws-session)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
(ns s-exp.mina.websocket.routing | ||
(:require [s-exp.mina.options :as options] | ||
[s-exp.mina.websocket.listener :as l]) | ||
(:import (io.helidon.webserver WebServerConfig$Builder) | ||
(io.helidon.webserver.websocket WsRouting WsRouting$Builder))) | ||
|
||
(set! *warn-on-reflection* true) | ||
|
||
(defn set-websocket-endpoints! ^WebServerConfig$Builder | ||
[^WebServerConfig$Builder builder endpoints _options] | ||
(doto builder | ||
(.addRouting | ||
(.build ^WsRouting$Builder | ||
(reduce (fn [^WsRouting$Builder builder [path listener]] | ||
(.endpoint builder ^String path (l/make-listener listener))) | ||
(WsRouting/builder) | ||
endpoints))))) | ||
|
||
(defmethod options/set-server-option! :websocket-endpoints | ||
[^WebServerConfig$Builder builder _ handler options] | ||
(set-websocket-endpoints! builder handler options)) |