Skip to content

Commit

Permalink
fix: correct check for websocket ping implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
sunng87 committed Apr 18, 2024
1 parent 3e38958 commit 2a260c5
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
3 changes: 3 additions & 0 deletions examples/rj9a/websocket.clj
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
(tap> [:ws :close status-code reason]))
:on-pong (fn [socket data]
(tap> [:ws :pong]))
:on-ping (fn [socket data]
(tap> [:ws :ping])
(ringws/pong socket))
:on-error (fn [socket error]
(.printStackTrace error)
(tap> [:ws :error error]))}
Expand Down
3 changes: 2 additions & 1 deletion project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
:resource-paths ["dev-resources/"]
:main ^:skip-aot rj9a.http3}
:example-websocket {:source-paths ["examples/"]
:dependencies [[org.eclipse.jetty/jetty-slf4j-impl ~jetty-version]]
:dependencies [[org.eclipse.jetty/jetty-slf4j-impl ~jetty-version]
[ring/ring-core "1.12.1"]]
:main ^:skip-aot rj9a.websocket}
:example-http {:source-paths ["examples/"]
:dependencies [[org.eclipse.jetty/jetty-slf4j-impl ~jetty-version]]
Expand Down
2 changes: 1 addition & 1 deletion src/ring/adapter/jetty9/websocket.clj
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
(^void onWebSocketBinary [this ^ByteBuffer payload ^Callback cb]
(ring-ws/on-message listener @session payload))
(^void onWebSocketPing [this ^ByteBuffer bytebuffer]
(when (extends? ring-ws/PingListener listener)
(when (satisfies? ring-ws/PingListener listener)
(ring-ws/on-ping listener @session bytebuffer)))
(^void onWebSocketPong [this ^ByteBuffer bytebuffer]
(ring-ws/on-pong listener @session bytebuffer)))))
Expand Down

0 comments on commit 2a260c5

Please sign in to comment.