Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Inuit_base.SocketA message Socket.controller is a bidirectional stream of message. The creator of a value of this type can:
message is received,val make : receive:('a -> unit) -> 'a controllermake ~receive creates a new controller that will call receive when a message is received.
val set_receive : 'a controller -> ('a -> unit) -> unitset_receive sets the callback invoked when a message is received.
set_on_closed sets the callback invoked when the connection terminates. Closing is definitive (it can happen at most once).
val set_on_closed : 'a controller -> (unit -> unit) -> unitset_on_closed sets the callback invoked when the connection terminates. Closing is definitive (it can happen at most once).
set_on_connected sets the callback invoked when the connection is established. It can be invoked at most once.
val set_on_connected : 'a controller -> (unit -> unit) -> unitset_on_connected sets the callback invoked when the connection is established. It can be invoked at most once.
val send : 'msg controller -> 'msg -> unitsend ctrl msg sends one message to the other end. status (endpoint ctrl) should be `Connected for this to succeed. Fail with Invalid_argument otherwise.
val close : 'msg controller -> unitclose ctrl terminates the connection now. If status (endpoint ctrl) is `Pending or `Connected, it is updated to `Closed and on_closed callback is invoked. If status (endpoint ctrl) is already `Closed, nothing happens.
val endpoint : 'a controller -> 'a tval status : 'msg t -> [ `Pending | `Connected | `Closed ]Get the status of the socket. Possible statuses are:
`Pending, connection has not been established yet, no message should be sent yet.`Connected, connection has been established, messages can be sent.`Closed, connection is terminated, no messages can be sent anymore.