Websocket_lwt.establish_server has the following signature:
val establish_server :
?timeout:int ->
?stop:unit Lwt.t ->
?random_string:Rng.t ->
ctx:Conduit_lwt_unix.ctx ->
mode:Conduit_lwt_unix.server ->
(int -> Cohttp.Request.t -> (unit -> Frame.t Lwt.t) -> (Frame.t -> unit Lwt.t) -> unit Lwt.t) ->
unit Lwt.t
I would like to get the connecting clients IP address, but the callback doesn't provide this info. It could be provided by passing the Conduit flow or the IP address directly.
If we're already breaking the signature, we could also make a new private type of which a value is passed to the callback, which contains all the information needed to send, receive and the other things, i.e.:
module Connected_client : sig
type t
val send : t -> Frame.t -> unit Lwt.t
val request : t -> Cohttp.Request.t
val ip : t -> Ipaddr.t
(* … *)
end
val establish_server :
?timeout:int ->
?stop:unit Lwt.t ->
?random_string:Rng.t ->
ctx:Conduit_lwt_unix.ctx ->
mode:Conduit_lwt_unix.server ->
(Connected_client.t -> unit Lwt.t) ->
unit Lwt.t
Websocket_lwt.establish_server
has the following signature:I would like to get the connecting clients IP address, but the callback doesn't provide this info. It could be provided by passing the Conduit flow or the IP address directly.
If we're already breaking the signature, we could also make a new private type of which a value is passed to the callback, which contains all the information needed to send, receive and the other things, i.e.: