Billstclair/elm-websocket-client

I burnt the midnight oil over the holiday weekend finishing my temporary standin for elm-lang/websocket. It works, and has a few additional features, but I’m still looking forward to the real upgrade, since the work you have to do to support a port package’s state is a pain, compared to the no work whatsoever that an effect module with kernel code can provide.

Package: https://package.elm-lang.org/packages/billstclair/elm-websocket-client/latest
Changelog: https://github.com/billstclair/elm-websocket-client/blob/2.0.2/CHANGELOG.md

Some possible extensions, which I’ll add if there’s demand:

  1. You currently must open, send, close yourself. I see no need for it, but some may still want support for just calling send, and having it automatically surrounded by open and close.

  2. It might be nice to be able to query the number and size of messages queued on the Elm side and the number of bytes in the output buffer on the JS side. I have already written support for the latter in the port code, but it’s not currently used anywhere.

  3. I used Evan’s backoff algorithm for reopening dropped connections, with an incrementing backoff going through (\backoff -> 10 * (2 ^ backoff)) to compute milliseconds. I limited mine to backoff <= 10, meaning the last delay is a little over 10 seconds, and it spends a total of a little under 20 seconds retrying the connection before giving up. It might be nice for the user to be able to specify the maximum value of backoff, or to provide her own (Int -> Maybe Int) function to turn an incrementing integer into milliseconds, returning Nothing when it’s time to give up.

4 Likes

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.