-
-
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
7 changed files
with
80 additions
and
31 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
6 changes: 2 additions & 4 deletions
6
src/s_exp/mina/response.clj → src/s_exp/mina/http/response.clj
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,49 @@ | ||
(ns s-exp.mina.websocket.handler | ||
(:require [s-exp.mina.options :as options]) | ||
(:import (io.helidon.common.buffers BufferData) | ||
(io.helidon.http Headers) | ||
(io.helidon.http HttpPrologue) | ||
(io.helidon.webserver WebServerConfig$Builder) | ||
(io.helidon.webserver.websocket WsRouting) | ||
(io.helidon.websocket WsListener WsSession) | ||
(java.util Optional))) | ||
|
||
(set! *warn-on-reflection* true) | ||
|
||
(defn make-listener | ||
^WsListener [{:as _listener | ||
:keys [message ping pong close error open http-upgrade] | ||
:or {message (constantly nil) | ||
ping (constantly nil) | ||
pong (constantly nil) | ||
close (constantly nil) | ||
error (constantly nil) | ||
open (constantly nil) | ||
http-upgrade (constantly (Optional/empty))}}] | ||
(reify WsListener | ||
(^void onMessage [_ ^WsSession session ^BufferData data ^boolean last?] | ||
(message session data last?)) | ||
(^void onPing [_ ^WsSession session ^BufferData data] | ||
(ping session data)) | ||
(^void onPong [_ ^WsSession session ^BufferData data] | ||
(pong session data)) | ||
(^void onClose [_ ^WsSession session ^int status ^String reason] | ||
(close session status reason)) | ||
(^void onError [_ ^WsSession session ^Throwable e] | ||
(error session e)) | ||
(^void onOpen [_ ^WsSession session] | ||
(open session)) | ||
(^Optional onHttpUpgrade [_ ^HttpPrologue http-prologue ^Headers headers] | ||
(http-upgrade http-prologue headers)))) | ||
|
||
(defn set-websocket-handler! ^WebServerConfig$Builder | ||
[^WebServerConfig$Builder builder [path listener] _options] | ||
(doto builder | ||
(.addRouting | ||
(.build | ||
(doto (WsRouting/builder) | ||
(.endpoint path (make-listener listener))))))) | ||
|
||
(defmethod options/set-server-option! :websocket-handler | ||
[^WebServerConfig$Builder builder _ handler options] | ||
(set-websocket-handler! builder handler options)) |
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