Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cohttp_lwt: may be pass frames_out_fn into incoming_handler? #113

Open
NightBlues opened this issue Sep 23, 2019 · 1 comment
Open

cohttp_lwt: may be pass frames_out_fn into incoming_handler? #113

NightBlues opened this issue Sep 23, 2019 · 1 comment

Comments

@NightBlues
Copy link

May be pass frames_out_fn into incoming_handler?
https://github.com/vbmithr/ocaml-websocket/blob/master/lwt/websocket_cohttp_lwt.ml#L40
Without frames_out_fn its hard to use incoming_handler to react to messages. You have to do something like

let out_fn = ref (fun _ -> ()) in
let on_message frame =
  (* TODO: parse frame *)
  !out_fn @@ Some (Frame.create ~opcode:Close ())
in
let%lwt resp, fr_out_fn = Websocket_cohttp_lwt.upgrade_connection req on_message in
out_fn := fr_out_fn

Or may be it should be done other way?

@vbmithr
Copy link
Owner

vbmithr commented Mar 5, 2020

I'm not using this piece of code anymore, and I have not looked closely but you're probably right. Feel free to submit a patch!
By the way, sorry for your other patch, merged now, I haven't look here for a long time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants