vbmithr / ocaml-websocket

Websocket library for OCaml
ISC License
161 stars 44 forks source link

Direct-style websockets with Eio #130

Open patricoferris opened 1 year ago

patricoferris commented 1 year ago

This PR adds direct-style websockets using eio and cohttp-eio (yet unreleased, but it has been merged in the main branch of mirage/ocaml-cohttp). It is WIP and probably will change, but I thought I would open this PR in case I don't have time to come back to it later.

cc: @bikallem @talex5 who might be able to comment on the core IO implementation a little :))

ryanslade commented 1 year ago

Is there anything holding back this PR for merge? Anything I can perhaps do to help push it over the line?

patricoferris commented 1 year ago

Is there anything holding back this PR for merge?

Thanks for the interest and offer for help @ryanslade. I would say this PR is blocked on landing a proper release of cohttp-eio. Right now, it is an alpha release and constrains us to eio.0.6 which means we also don't have access to Eio.Buf_read.BE for example. There is some experimentation on what a good HTTP library might look like, see https://github.com/mirage/ocaml-cohttp/pull/969 but I think this implies it's going to be a while before we see a full release of cohttp-eio.

ushitora-anqou commented 8 months ago

Hi. Cohttp 6.0.0~beta1 is out and it has Cohttp_eio.Private.IO module, which implements Cohttp.S.IO. As the Lwt version of ocaml-websocket does, we can feed it to Websocket.Make to get the necessary functions for WS server and client implementations. Personally, I needed an Eio version of a WS client implementation and tried this strategy, which worked just fine. I have left the code here for anyone who needs it.