talircd/lib/server/outbox.ml

15 lines
328 B
OCaml
Raw Normal View History

open! Import
type t = {
stream : Irc.Msg.t Lwt_stream.t;
push : Irc.Msg.t option -> unit;
}
let make () =
let stream, push = Lwt_stream.create () in
{ stream; push }
let stream t = t.stream
let send t msg = try t.push (Some msg) with Lwt_stream.Closed -> ()
let close t = try t.push None with Lwt_stream.Closed -> ()