Hello, I am using ring.websocket and holding the connected clients in an atom with a set:
(def connected-clients (atom #{}))
I want to know the structure of the objects inside.
They look like on the repl:
#{#object[ring.adapter.jetty$websocket_socket$reify__1849 0x46284a01 "ring.adapter.jetty$websocket_socket$reify__1849@46284a01"]
#object[ring.adapter.jetty$websocket_socket$reify__1849 0x8fac8d "ring.adapter.jetty$websocket_socket$reify__1849@8fac8d"]
#object[ring.adapter.jetty$websocket_socket$reify__1849 0x74975dbc "ring.adapter.jetty$websocket_socket$reify__1849@74975dbc"]}
A bit new to clojure and ring and want to know how to inspect them, and find out their structure. How to do that?Thank you. So there is not identifiers in there I guess.
Nope. For that you'll need to add information from the request map.
Anything specific from request map? I could not see much direct identifiers: https://github.com/ring-clojure/ring/blob/master/SPEC.md#14-request-maps Or did you mean I need to utilize my custom solution with a middleware (as it will modify request map with my custom identifier)?
What do you mean by "identifier"? The request map gives you access to things like the remote (client) address and the session store. But if you want your own identifier, for example a UUID, you'd need to add that in yourself. I often use a map to relate a generated ID with its corresponding socket.
Some socket id or something like that to use it if already exist. Yes that is want I thought of doing but looking for ideas and maybe functionality that I have missed from the docs. As I could not look into what socket objects are previously .Thank you very much. I might use an atom with a set maybe or a map.
They're described in the Ring https://github.com/ring-clojure/ring/blob/master/SPEC.md#33-websocket-sockets. They're opaque objects that satisfy the ring.websocket.protocols/Socket protocol.
You can interact with the sockets via the functions in the https://ring-clojure.github.io/ring/ring.websocket.html namespace.