aboutsummaryrefslogtreecommitdiff
path: root/lib/client.ml
diff options
context:
space:
mode:
authorMishio595 <[email protected]>2018-11-24 09:51:03 -0700
committerMishio595 <[email protected]>2018-11-24 09:51:03 -0700
commitd342c4cf9fe907d2107cd815f9988f8ad147218b (patch)
treefebb926d6f3e1956346db2d3ee952391b193deb9 /lib/client.ml
parentAdd opam build file (diff)
downloaddisml-d342c4cf9fe907d2107cd815f9988f8ad147218b.tar.xz
disml-d342c4cf9fe907d2107cd815f9988f8ad147218b.zip
Major structural changes
Diffstat (limited to 'lib/client.ml')
-rw-r--r--lib/client.ml35
1 files changed, 35 insertions, 0 deletions
diff --git a/lib/client.ml b/lib/client.ml
new file mode 100644
index 0000000..7c2d532
--- /dev/null
+++ b/lib/client.ml
@@ -0,0 +1,35 @@
+open Async
+
+type t = {
+ sharder: Sharder.t Ivar.t;
+ handler: (string * Model.t) Pipe.Writer.t;
+ token: string;
+}
+
+let make ~handler token =
+ {
+ sharder = Ivar.create ();
+ handler;
+ token;
+ }
+
+let start ?count client =
+ Sharder.start ?count ~handler:client.handler client.token
+ >>| fun sharder ->
+ Ivar.fill_if_empty client.sharder sharder;
+ client
+
+let set_status client status =
+ Ivar.read client.sharder
+ >>= fun sharder ->
+ Sharder.set_status sharder status
+
+let set_status_with client f =
+ Ivar.read client.sharder
+ >>= fun sharder ->
+ Sharder.set_status_with sharder f
+
+let request_guild_members ~guild ?query ?limit client =
+ Ivar.read client.sharder
+ >>= fun sharder ->
+ Sharder.request_guild_members ~guild ?query ?limit sharder