Module Hub

module Hub: Hub

module Client_id: sig .. end
type ('from_client, 'to_client) t 
val create : ?buffer_age_limit:Async.Std.Writer.buffer_age_limit ->
([ `Passive ], Async.Std.Socket.Address.Inet.t) Async.Std.Socket.t ->
('a, 'b) t Async.Std.Deferred.t
val close : ('a, 'b) t -> unit Async.Std.Deferred.t
val listen : ('a, 'b) t ->
[ `Connect of Client_id.t
| `Data of Client_id.t * 'a
| `Disconnect of Client_id.t * string ] Async.Std.Pipe.Reader.t
listen 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, 'b) t -> (Client_id.t * 'a) Async.Std.Pipe.Reader.t
val send : ('b, 'a) t -> Client_id.t -> 'a -> unit
val send_to_all : ('b, 'a) t -> 'a -> unit
val flushed : ('a, 'b) t -> unit Async.Std.Deferred.t
val clients : ('a, 'b) t -> Client_id.t list
val open_channel : ('a, 'b) t -> ('a, 'b) Channel.t Async.Std.Deferred.t
open_channel may be called even in a different process than the creator of the hub.
val socket : ('a, 'b) t -> Async.Std.Unix.Inet_addr.t * int