-
Notifications
You must be signed in to change notification settings - Fork 2
/
mqtt_async.mli
104 lines (102 loc) · 2.95 KB
/
mqtt_async.mli
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
val keep_alive_timer_interval_default : float
val keepalive : int
val version : int
val msg_id : int ref
val string_of_char : char -> string
val print_str : string -> unit
val int_to_str2 : int -> string
val encode_string : string -> string
val str2_to_int : string -> int
val get_msg_id_bytes : string
val charlist_to_str : char list -> string
val str_to_charlist : string -> char list
val str_to_intlist : string -> int list
module type CONN = sig
type reader
type writer
type t
val connect: host:string -> port:int -> t
end
module Connection :
sig
type t = { reader : Async_unix.Reader.t; writer : Async_unix.Writer.t; }
end
type msg_type =
CONNECT
| CONNACK
| PUBLISH
| PUBACK
| PUBREC
| PUBREL
| PUBCOMP
| SUBSCRIBE
| SUBACK
| UNSUBSCRIBE
| UNSUBACK
| PINGREQ
| PINGRESP
| DISONNECT
| RESERVED
type header_t = {
msg : msg_type;
dup : bool;
qos : int;
retain : bool;
remaining_len : int;
mutable buffer : string;
}
type packet_t = {
header : header_t;
topic : string;
msg_id : int;
payload : string option;
}
val pr : packet_t Async.Std.Pipe.Reader.t
val pw : packet_t Async.Std.Pipe.Writer.t
val msg_type_to_int : msg_type -> int
val msg_type_to_str : msg_type -> string
val int_to_msg_type : int -> msg_type option
val get_remaining_len : Async_unix.Reader.t -> int Async_kernel.Deferred.t
val msg_header : msg_type -> bool -> int -> bool -> char
val get_header : Async_unix.Reader.t -> header_t Async_kernel.Deferred.t
val receive_packet :
Async_unix.Reader.t ->
(header_t, string) Core_kernel.Std_kernel._result Async_kernel.Deferred.t
val send_puback :
Async_unix.Writer.t -> string -> unit Async_kernel.Deferred.t
val receive_packets :
Async_unix.Reader.t -> Async_unix.Writer.t -> unit Async_kernel.Deferred.t
val process_publish_pkt : (string -> string -> int -> unit) -> unit
val receive_connack :
Async_unix.Reader.t ->
(string, string) Core_kernel.Std_kernel._result Async_kernel.Deferred.t
val connect : host:string -> port:int -> Connection.t Async_kernel.Deferred.t
val send_ping_req : Async_unix.Writer.t -> unit Async_kernel.Deferred.t
val ping_loop :
?interval:float -> Async_unix.Writer.t -> 'a Async_kernel.Deferred.t
val multi_byte_len : int -> int list
val subscribe : ?qos:int -> topics:string list -> Async_unix.Writer.t -> unit
val unsubscribe :
?qos:int -> topics:string list -> Async_unix.Writer.t -> unit
val publish :
?dup:bool ->
?qos:int ->
?retain:bool ->
topic:string ->
payload:string -> Async_unix.Writer.t -> unit Async_kernel.Deferred.t
val publish_periodically :
?qos:int ->
?period:float ->
topic:string -> (unit -> string) -> Async_unix.Writer.t -> unit
val connect_to_broker :
?keep_alive_interval:float ->
?dup:bool ->
?qos:int ->
?retain:bool ->
?username:string ->
?password:string ->
?will_message:string ->
?will_topic:string ->
?clean_session:bool ->
?will_qos:int ->
?will_retain:bool -> broker:string -> port:int -> (Connection.t -> 'a) -> unit