package async_extra

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type
type t
val create' : ?logfun: < recv : To_client_msg.t ; send : To_server_msg.t ; remote_name : Server_name.t > logfun -> ?now:(unit -> Core.Time.t) -> ?check_remote_name:bool -> ?credentials:string -> ip:string -> port:int -> expected_remote_name:Server_name.t -> Client_name.t -> t

create a new (initially disconnected) client

val create : ?logfun: < recv : To_client_msg.t ; send : To_server_msg.t ; remote_name : Server_name.t > logfun -> ?now:(unit -> Core.Time.t) -> ?check_remote_name:bool -> ip:string -> port:int -> expected_remote_name:Server_name.t -> Client_name.t -> t

Just like create', but assume empty credentials (for backwards compatibility)

val connect : t -> unit Async_kernel.Deferred.t

connect t If the connection is not currently established, initiate one. Returns a deferred that becomes determined when the connection is established.

val close_connection : t -> unit

If a connection is currently established, close it. Also, if we're trying to connect, give up.

listen t

  • returns

    a stream of messages from the server and errors

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

listen_ignore_errors t like listen, but with no errors or meta data. 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), so you should not call it many times throwing away the result. If you need to do this use listen.

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

send t msg send a message to the server. If the connection is not currently established, initiate one.

  • returns

    a deferred that is filled in with either the time the message was handed to the OS, or `Dropped. `Dropped means that there was an error, and the message will not be sent.

val send_ignore_errors : t -> To_server_msg.t -> unit

send_ignore_errors t exactly like send but with no error reporting.

val state : t -> [ `Disconnected | `Connected | `Connecting ]

state t

  • returns

    the state of the connection

val last_connect_error : t -> Core.Error.t option

last_connect_error t returns the error (if any) that happened on the last connection attempt.

val flushed : t -> [ `Flushed | `Pending of Core.Time.t Async_kernel.Deferred.t ]