-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmessage.ml
55 lines (50 loc) · 1.5 KB
/
message.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
(*
Copyright (c) Mihhail Aizatulin ([email protected]).
This file is distributed under a BSD license.
See LICENSE file for copyright notice.
*)
open Base
open Std_internal
module Init = struct
type 'a t =
{ boxes : (Box_id.t * 'a Box.Local.t * Client_id.t option) list
; width : float
; height : float
; time : Time.t
} [@@deriving sexp]
end
(* CR: move client_id out *)
type 'a t =
| Request of (Client_id.t * Box_id.t)
| Grant of (Client_id.t * Box_id.t)
| Release of Box_id.t
| Add of (Client_id.t * Box_id.t * 'a Box.Local.t)
| Set of (Client_id.t * Box_id.t * 'a Box.Local.t)
| Delete of Box_id.t
| Request_init of (Client_id.t * Faye.Channel.t)
| Init of 'a Init.t
| Max_clients_exceeded of (Client_id.t * int)
[@@deriving sexp]
(*
let to_string = function
| Request _ -> "Request"
| Grant _ -> "Grant"
| Release _ -> "Release"
| Add _ -> "Add"
| Set (_, _, shape) -> Printf.sprintf "Set %s" (Box.Local.to_string shape)
| Delete _ -> "Delete"
| Init _ -> "Init"
| Request_init _ -> "Request_init"
| Max_clients_exceeded (_, max_clients) ->
Printf.sprintf "Max_clients_exceeded %d" max_clients
*)
let client_id = function
| Request (client_id, _) -> Some client_id
| Release _ -> None
| Grant (client_id, _) -> Some client_id
| Add (client_id, _, _) -> Some client_id
| Set (client_id, _, _) -> Some client_id
| Delete _ -> None
| Request_init (client_id, _) -> Some client_id
| Init _ -> None
| Max_clients_exceeded _ -> None