| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# You may distribute under the terms of either the GNU General Public License |
|
2
|
|
|
|
|
|
|
# or the Artistic License (the same terms as Perl itself) |
|
3
|
|
|
|
|
|
|
# |
|
4
|
|
|
|
|
|
|
# (C) Paul Evans, 2016 -- leonerd@leonerd.org.uk |
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
package App::MatrixTool::Command::client::sync; |
|
7
|
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
722
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
26
|
|
|
9
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
24
|
|
|
10
|
1
|
|
|
1
|
|
3
|
use base qw( App::MatrixTool::Command::client ); |
|
|
1
|
|
|
|
|
0
|
|
|
|
1
|
|
|
|
|
145
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = '0.08'; |
|
13
|
|
|
|
|
|
|
|
|
14
|
1
|
|
|
1
|
|
5
|
use Future::Utils qw( repeat ); |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
60
|
|
|
15
|
|
|
|
|
|
|
|
|
16
|
1
|
|
|
1
|
|
4
|
use constant DESCRIPTION => "Follow the /sync event stream"; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
76
|
|
|
17
|
1
|
|
|
1
|
|
4
|
use constant ARGUMENTS => (); |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
43
|
|
|
18
|
1
|
|
|
|
|
225
|
use constant OPTIONS => ( |
|
19
|
|
|
|
|
|
|
'i|initial' => "Print the initial sync result too", |
|
20
|
1
|
|
|
1
|
|
4
|
); |
|
|
1
|
|
|
|
|
1
|
|
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 NAME |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
matrixtool client sync - Follow the C event stream |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
$ matrixtool client -u @me:example.com sync |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
This command follows the event stream from the homeserver by making repeated |
|
33
|
|
|
|
|
|
|
calls to the C API, printing the returned values. |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head1 OPTIONS |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=over 4 |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=item C<--initial>, C<-i> |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
Include the initial C result in the output, as well as ongoing updates. |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=back |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=cut |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub run |
|
48
|
|
|
|
|
|
|
{ |
|
49
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
50
|
0
|
|
|
|
|
|
my ( $opts ) = @_; |
|
51
|
|
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
|
my $token; |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
repeat { |
|
55
|
|
|
|
|
|
|
$self->do_json( GET => "/_matrix/client/r0/sync", |
|
56
|
|
|
|
|
|
|
params => { |
|
57
|
|
|
|
|
|
|
timeout => 30*1000, |
|
58
|
|
|
|
|
|
|
( defined $token ) ? ( since => $token ) : (), |
|
59
|
|
|
|
|
|
|
} |
|
60
|
|
|
|
|
|
|
)->then( sub { |
|
61
|
0
|
|
|
|
|
|
my ( $body ) = @_; |
|
62
|
|
|
|
|
|
|
|
|
63
|
0
|
0
|
0
|
|
|
|
if( defined $token or $opts->{initial} ) { |
|
64
|
0
|
|
|
|
|
|
print "---\n"; |
|
65
|
0
|
|
|
|
|
|
print $self->JSON_pretty->encode( $body ); |
|
66
|
|
|
|
|
|
|
} |
|
67
|
|
|
|
|
|
|
|
|
68
|
0
|
|
|
|
|
|
$token = $body->{next_batch}; |
|
69
|
0
|
|
|
|
|
|
Future->done; |
|
70
|
0
|
0
|
|
0
|
|
|
}); |
|
71
|
0
|
|
|
0
|
|
|
} while => sub { !$_[0]->failure }; |
|
|
0
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
} |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head1 AUTHOR |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
Paul Evans |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=cut |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
0x55AA; |