File tree Expand file tree Collapse file tree 1 file changed +28
-21
lines changed Expand file tree Collapse file tree 1 file changed +28
-21
lines changed Original file line number Diff line number Diff line change 601
601
:channel-inactive
602
602
([_ ctx]
603
603
(when (realized? d)
604
- (s/close! @d))
604
+ ; ; close only on success
605
+ (d/chain' d s/close!))
605
606
(.fireChannelInactive ctx))
606
607
607
608
:channel-active
618
619
(cond
619
620
620
621
(not (.isHandshakeComplete handshaker))
621
- (d/chain'
622
- (netty/wrap-future (.processHandshake handshaker ch msg))
623
- (fn [_]
624
- (let [out (netty/sink ch false
625
- (fn [c]
626
- (if (instance? CharSequence c)
627
- (TextWebSocketFrame. (bs/to-string c))
628
- (BinaryWebSocketFrame. (netty/to-byte-buf ctx c))))
629
- (fn [] @desc))]
630
-
631
- (d/success! d
632
- (doto
633
- (s/splice out @in)
634
- (reset-meta! {:aleph/channel ch})))
635
-
636
- (s/on-drained @in
637
- #(when (.isOpen ch)
638
- (d/chain'
639
- (netty/wrap-future (.close handshaker ch (CloseWebSocketFrame. )))
640
- (fn [_] (netty/close ctx))))))))
622
+ (-> (netty/wrap-future (.processHandshake handshaker ch msg))
623
+ (d/chain'
624
+ (fn [_]
625
+ (let [out (netty/sink ch false
626
+ (fn [c]
627
+ (if (instance? CharSequence c)
628
+ (TextWebSocketFrame. (bs/to-string c))
629
+ (BinaryWebSocketFrame. (netty/to-byte-buf ctx c))))
630
+ (fn [] @desc))]
631
+
632
+ (d/success! d
633
+ (doto
634
+ (s/splice out @in)
635
+ (reset-meta! {:aleph/channel ch})))
636
+
637
+ (s/on-drained @in
638
+ #(when (.isOpen ch)
639
+ (d/chain'
640
+ (netty/wrap-future (.close handshaker ch (CloseWebSocketFrame. )))
641
+ (fn [_] (netty/close ctx))))))))
642
+ (d/catch'
643
+ (fn [ex]
644
+ ; ; handle handshake exception
645
+ (d/error! d ex)
646
+ (s/close! @in)
647
+ (netty/close ctx))))
641
648
642
649
(instance? FullHttpResponse msg)
643
650
(let [rsp ^FullHttpResponse msg]
You can’t perform that action at this time.
0 commit comments