package async_extra

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type
type t
include Async_kernel.Invariant.S with type t := t
val invariant : t -> unit
val create : ?logfun: < send : To_client_msg.t ; recv : To_server_msg.t ; remote_name : Client_name.t > logfun -> ?now:(unit -> Core.Time.t) -> ?enforce_unique_remote_name:bool -> ?is_client_ip_authorized:(string -> bool) -> ?warn_when_free_connections_lte_pct:float -> ?max_clients:int -> listen_port:int -> Server_name.t -> t Async_kernel.Deferred.t

create a new server, and start listening

val port : t -> int

get the port that the server is listening on

val close : t -> Client_name.t -> unit

close t client close connection to client if it exists. This does not prevent the same client from connecting again later.

listen t listen to the stream of messages and errors coming from clients

val listen_ignore_errors : ?stop:unit Async_kernel.Deferred.t -> t -> To_server_msg.t Async_kernel.Stream.t

listen_ignore_errors t like listen, but omit error conditions and metadata. When listen_ignore_errors is called it installs a filter on the stream that never goes away (unless t is destroyed, or you provide a stop).

val send : t -> Client_name.t -> To_client_msg.t -> [ `Sent of Core.Time.t | `Dropped ] Async_kernel.Deferred.t

send t client msg send msg to client.

  • returns

    a deferred that will become determined when the message has been sent. In the case of an error, the message will be dropped, and the deferred will be filled with `Dropped (meaning the message was never handed to the OS), otherwise it will be filled with with `Sent tm where tm is the time (according to Time.now) that the message was handed to the operating system. It is possible that the deferred will never become determined, for example in the case that the other side hangs, but does not drop the connection.

val send_ignore_errors : t -> Client_name.t -> To_client_msg.t -> unit

send_ignore_errors t client msg Just like send, but does not report results. Your message will probably be sent successfully sometime after you call this function. If you receive a Disconnect error on the listen channel in close time proximity to making this call then your message was likely dropped.

val send_to_all : t -> To_client_msg.t -> [ `Sent | `Dropped | `Partial_success ] Async_kernel.Deferred.t

send_to_all t msg send the same message to all connected clients.

val send_to_all_ignore_errors : t -> To_client_msg.t -> unit

send_to_all_ignore_errors t msg Just like send_to_all but with no error reporting.

val send_to_some : t -> To_client_msg.t -> Client_name.t list -> [ `Sent | `Dropped | `Partial_success ] Async_kernel.Deferred.t

send_to_some t msg names send the same message to multiple connected clients.

val send_to_some_ignore_errors : t -> To_client_msg.t -> Client_name.t list -> unit

send_to_some_ignore_errors t msg Just like send_to_some but with no error reporting.

val client_send_version : t -> Client_name.t -> Version.t option
val client_is_connected : t -> Client_name.t -> bool
val flushed : t -> cutoff:unit Async_kernel.Deferred.t -> ([ `Flushed of Client_name.t list ] * [ `Not_flushed of Client_name.t list ]) Async_kernel.Deferred.t
val shutdown : t -> unit Async_kernel.Deferred.t
val shutdown_and_disconnect_clients : t -> unit Async_kernel.Deferred.t