File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11(ns slack-rtm.core
2+ (:import (org.eclipse.jetty.websocket.client WebSocketClient)
3+ (org.eclipse.jetty.util.ssl SslContextFactory))
24 (:require [clj-slack.rtm :as rtm]
35 [clj-slack.core :refer [slack-request]]
46 [clojure.core.async :as async
2628 (recur ))))
2729 ch))
2830
31+ (defn- client
32+ " Create a new instance of `WebSocketClient` with max-text-message-size.
33+ (for https://github.com/stalefruits/gniazdo/issues/22)"
34+ [max-text-message-size]
35+ (let [client (WebSocketClient. (SslContextFactory. ))]
36+ (try
37+ (when max-text-message-size
38+ (.setMaxTextMessageSize (.getPolicy client) max-text-message-size))
39+ (.start client)
40+ (catch Throwable ex
41+ (.stop client)
42+ (throw ex)))))
43+
2944(defn- ws-connect
3045 " Connects to the provided WebSocket URL and forward all listener
3146 events to the provided channel."
32- [url callback-ch]
47+ [url callback-ch { :keys [max-text-message-size] :as connection} ]
3348 (ws/connect
3449 url
50+ :client (client max-text-message-size)
3551 :on-connect #(go (>! callback-ch {:type :on-connect
3652 :session %}))
3753
101117(defn- build-connection-map [token-or-map]
102118 (if (string? token-or-map)
103119 {:api-url " https://slack.com/api"
104- :token token-or-map}
120+ :token token-or-map
121+ :max-text-message-size 65536 }
105122 token-or-map))
106123
107124(defn- internal-connect
154171 ; ; get a channel that can be used to send data to slack
155172 dispatcher (-> start
156173 :url
157- (ws-connect callback-ch)
174+ (ws-connect callback-ch connection )
158175 spin-dispatcher-channel)]
159176 {:start start
160177 :websocket-publication websocket-publication
You can’t perform that action at this time.
0 commit comments