Clojure WebSocket Client

前端 未结 6 829
死守一世寂寞
死守一世寂寞 2021-02-07 05:40

I have set up a WebSocket server using http-kit that should accept web socket connections. It is the basic example shown in the http-kit documentation.

The quest

6条回答
  •  逝去的感伤
    2021-02-07 06:18

    I built a basic websocket client and server, it uses java sockets and wraps websocket frames. It's unique in that the server can accept both regular socket connections as well as websockets, simultaneously.

    http://github.com/viperscape/gulfstream

    Example client code:

    (def clienthandler
      (with-conn server
        (send! server "i'm here!")
        (with-data server data (prn "client received" data))
        (prn "client is now disconnected")))
    
    (def ws-conn-details {:host "ws://echo.websocket.org/chat",:handler clienthandler})
    
    (def client-conn (start-client ws-conn-details))
    

提交回复
热议问题