Skip to content

cohttp_lwt: may be pass frames_out_fn into incoming_handler? #113

Open
@NightBlues

Description

@NightBlues

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions