yada

OliverM 2018-10-31T11:21:25.000900Z

I’m about to try integrating websockets into a yada handler. Are there any gotchas I should be aware of? I know Sente has support for Aleph so I was just going to go the Sente route as a first attempt

mccraigmccraig 2018-10-31T11:28:57.002200Z

@oliver.mooney we use the aleph websocket support and a ring handler - it's lower-level than yada, but it's straightforward and operates happily alongside other yada handlers

OliverM 2018-10-31T11:29:39.002500Z

@mccraigmccraig good to know, thanks

borkdude 2018-10-31T12:12:54.003400Z

@oliverm I used server sent events, it was painless with yada / aleph

borkdude 2018-10-31T12:13:05.003700Z

(why do you have two accounts…, I don’t know which one to at)

borkdude 2018-10-31T12:13:17.004100Z

If you want to know more, google for the yada chat application

borkdude 2018-10-31T12:20:06.005700Z

How I use it: I send a small message to the client that something should be updated. Then the client does the request to the server using the same logic that was already in place in Re-frame, etc. No special code needed

borkdude 2018-10-31T12:20:35.005900Z

And all of the auth still works.

OliverM 2018-10-31T12:21:51.007100Z

@borkdude thanks, I was thinking of using SSE for broadcasts but you use it to ping a particular client to pull updates from the server? Do your clients use normal http methods to return data to the server, so no websockets at all?

OliverM 2018-10-31T12:22:24.007600Z

Sorry about the two accounts, a previous job required me to make a separate one that’s now derelict :face_with_rolling_eyes:

borkdude 2018-10-31T12:22:38.007900Z

yeah, I ping particular clients.

OliverM 2018-10-31T12:22:54.008200Z

hmm that could work really well, thanks for the pointer

borkdude 2018-10-31T12:23:27.008900Z

just store the channel(s) (plural if you want to support multiple open tabs) per client in an atom somewhere, by user-id

borkdude 2018-10-31T12:23:37.009200Z

and then choose those, doseq over them and put a message in them

OliverM 2018-10-31T12:23:53.009500Z

seems super straightforward, great

borkdude 2018-10-31T12:27:56.010Z

yeah, note that you also have to deal with closed channel when the user closes a tab, but you’ll figure it out

👍 1
dominicm 2018-10-31T18:54:19.011500Z

SSE is significantly superior to WebSockets for most things. King of them is that authorization works, and you don't need to develop your own scheme on top.

dominicm 2018-10-31T18:55:08.012800Z

Games are the only use case that need the low latency that WS provides, as far as I know. Maybe chat too @mccraigmccraig? But you would need to convince me 😊

malcolmsparks 2018-10-31T20:00:43.018100Z

There's an example of using websockets in Edge (https://github.com/juxt/edge). We use it to do Graphql subscriptions, mostly because the Graphiql console is more mature for WS although we could have made it work with SSE too. You can use thr Authorisation header when upgrading the protocol to WS.

mccraigmccraig 2018-10-31T20:17:47.021200Z

i’ve no idea what the sse latency is like @dominicm but unless it’s pretty bad it will probably be fine for chat... websockets were pretty trivial to implement tho, auth & all

mccraigmccraig 2018-10-31T20:21:00.024900Z

one nice thing about the websocket api - it’s a bi-directional socket, so the client can keep on sending messages to modify what the server end is doing - we use this to subscribe and unsubscribe a user’s websocket to different topics of interest as the user moves around in the app

dominicm 2018-10-31T20:22:23.025700Z

My information is apparently incorrect with regards to authentication.