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.
Some possible extensions, which I’ll add if there’s demand:
You currently must
closeyourself. I see no need for it, but some may still want support for just calling
send, and having it automatically surrounded by
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.
I used Evan’s backoff algorithm for reopening dropped connections, with an incrementing
(\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
Nothingwhen it’s time to give up.