summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorMatias Linares <matias@deprecated.org>2018-09-08 12:47:13 -0300
committerMatias Linares <matias@deprecated.org>2018-09-08 12:47:13 -0300
commit2aab03cd0db9854ffc787dc7c2d2c790bc84cc50 (patch)
treed8380446b51b636a1886451678207186159e2a7b /examples
parentb0643e39808930d2ea5a04f1a35e9b1e14e06861 (diff)
downloadperl6-matrix-client-2aab03cd0db9854ffc787dc7c2d2c790bc84cc50.tar.gz
Add run example.
Diffstat (limited to 'examples')
-rw-r--r--examples/run.p621
1 files changed, 21 insertions, 0 deletions
diff --git a/examples/run.p6 b/examples/run.p6
new file mode 100644
index 0000000..f78df16
--- /dev/null
+++ b/examples/run.p6
@@ -0,0 +1,21 @@
+#!/usr/bin/env perl6
+use v6;
+use lib <lib>;
+use Matrix::Client;
+
+sub MAIN(Str:D $username, Str:D $password, :$home-server = "https://matrix.deprecated.org") {
+ my Matrix::Client $client .= new: :$home-server;
+ $client.login($username, $password);
+
+ my $sup = $client.run(:sleep<5>);
+
+ signal(SIGINT).tap({
+ say "Bye";
+ $client.logout;
+ exit 0;
+ });
+
+ react whenever $sup -> $ev {
+ say $ev;
+ }
+}