-
Notifications
You must be signed in to change notification settings - Fork 125
/
bslClientEvent.ml
64 lines (49 loc) · 2.36 KB
/
bslClientEvent.ml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
(*
Copyright © 2011 MLstate
This file is part of OPA.
OPA is free software: you can redistribute it and/or modify it under the
terms of the GNU Affero General Public License, version 3, as published by
the Free Software Foundation.
OPA is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
more details.
You should have received a copy of the GNU Affero General Public License
along with OPA. If not, see <http://www.gnu.org/licenses/>.
*)
(*
@author Francois Pessaux
*)
##extern-type ClientEvent.t = BslPingRegister.M.event
##extern-type ClientEventKey.t = BslPingRegister.M.event_key
##register connect : ClientEvent.t
let connect = BslPingRegister.M.Connect
##register disconnect : ClientEvent.t
let disconnect = BslPingRegister.M.Disconnect
(* ************************************************************************** *)
(* Magic conversion of a [BslUtils.opa_threadcontext_client] into a
[BslPingRegister.Client.key]. Used by [register_event] below. *)
(* ************************************************************************** *)
external opa_tc_c_2_bsl_pr_c_k :
BslUtils.opa_threadcontext_client -> BslPingRegister.Client.key =
"%identity"
(* ************************************************************************** *)
(* Magic conversion of a [BslPingRegister.Client.key] into a
[BslUtils.opa_threadcontext_client]. Used by [register_event] below. *)
(* ************************************************************************** *)
external bsl_pr_c_k_2_opa_tc_c :
BslPingRegister.Client.key -> BslUtils.opa_threadcontext_client =
"%identity"
##register register_event : option(opa[ThreadContext.client]), \
ClientEvent.t, \
(opa[ThreadContext.client] -> void) -> \
ClientEventKey.t
let register_event opt_tcc ce cb =
let opt_tcc' =
match opt_tcc with
| None -> None
| Some tcc -> Some (opa_tc_c_2_bsl_pr_c_k tcc) in
let cb' x = cb (bsl_pr_c_k_2_opa_tc_c x) in
BslPingRegister.M.register_event opt_tcc' ce cb'
##register remove_event : ClientEventKey.t -> void
let remove_event = BslPingRegister.M.remove_event