A hub is a place to which any number (possibly zero) of clients can connect a channel and send messages. The process in which the hub is created is responsible for listening to the messages clients send, and can send messages to an individual client, or broadcast a message to all clients.
Unless otherwise noted none of the below functions may be called in a process other than the one that created the hub.
module Client_id : sig ... endval create : ?buffer_age_limit:Async.Writer.buffer_age_limit ‑> ([ `Passive ], Async.Socket.Address.Inet.t) Async.Socket.t ‑> (_, _) t Async.Deferred.tval close : (_, _) t ‑> unit Async.Deferred.tval listen : ('a, _) t ‑> [ `Connect of Client_id.t | `Disconnect of Client_id.t * string | `Data of Client_id.t * 'a ] Async.Pipe.Reader.tlisten and listen_simple start a loop that accepts connections from clients
that wish to open channels connected to the hub. listen_simple returns the
sequence of messages sent by clients. listen returns those, intermixed with
messages indicating when clients `Connect and `Disconnect.
listen or listen_simple should be called exactly once for a given hub.
Subsequent calls will raise.
val listen_simple : ('a, _) t ‑> (Client_id.t * 'a) Async.Pipe.Reader.tval send : (_, 'a) t ‑> Client_id.t ‑> 'a ‑> unitval send_to_all : (_, 'a) t ‑> 'a ‑> unitval flushed : (_, _) t ‑> unit Async.Deferred.tval clients : (_, _) t ‑> Client_id.t listval open_channel : ('a, 'b) t ‑> ('a, 'b) Channel.t Async.Deferred.topen_channel may be called even in a different process than the creator of the hub.
val socket : (_, _) t ‑> Async.Unix.Inet_addr.t * int