| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
1
|
|
|
1
|
|
609
|
use v5.42; |
|
|
1
|
|
|
|
|
4
|
|
|
2
|
1
|
|
|
1
|
|
5
|
use feature 'class'; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
178
|
|
|
3
|
1
|
|
|
1
|
|
6
|
use experimental 'try'; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
6
|
|
|
4
|
1
|
|
|
1
|
|
73
|
no warnings 'experimental::class'; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
79
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
class At::Protocol::Firehose 1.0 { |
|
7
|
1
|
|
|
1
|
|
5
|
use At::Error; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
5
|
|
|
8
|
1
|
|
|
1
|
|
441
|
use Codec::CBOR; |
|
|
1
|
|
|
|
|
2846
|
|
|
|
1
|
|
|
|
|
444
|
|
|
9
|
|
|
|
|
|
|
field $at : param; |
|
10
|
|
|
|
|
|
|
field $url : param : reader //= 'wss://bsky.network/xrpc/com.atproto.sync.subscribeRepos'; |
|
11
|
|
|
|
|
|
|
field $callback : param; |
|
12
|
|
|
|
|
|
|
field $codec; |
|
13
|
|
|
|
|
|
|
ADJUST { |
|
14
|
|
|
|
|
|
|
# Ensure url is absolute |
|
15
|
|
|
|
|
|
|
$url = 'wss://' . $url if $url !~ m[^wss?://]; |
|
16
|
|
|
|
|
|
|
$codec = Codec::CBOR->new(); |
|
17
|
|
|
|
|
|
|
} |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
method start() { |
|
20
|
1
|
|
|
|
|
3
|
$at->http->websocket( |
|
21
|
1
|
|
|
1
|
|
433
|
$url => sub ( $msg, $err ) { |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
2
|
|
|
22
|
1
|
0
|
33
|
|
|
7
|
return if !$msg && !defined $err; |
|
23
|
1
|
50
|
|
|
|
5
|
if ( defined $err ) { |
|
24
|
0
|
|
|
|
|
0
|
$callback->( undef, undef, $err ); |
|
25
|
0
|
|
|
|
|
0
|
return; |
|
26
|
|
|
|
|
|
|
} |
|
27
|
1
|
50
|
33
|
|
|
7
|
return unless defined $msg && length $msg; |
|
28
|
1
|
|
|
|
|
3
|
try { |
|
29
|
1
|
|
|
|
|
7
|
my @objects = $codec->decode_sequence($msg); |
|
30
|
1
|
50
|
|
|
|
463
|
if ( @objects >= 2 ) { |
|
|
|
0
|
|
|
|
|
|
|
31
|
1
|
|
|
|
|
5
|
$callback->( $objects[0], $objects[1], undef ); |
|
32
|
|
|
|
|
|
|
} |
|
33
|
|
|
|
|
|
|
elsif ( @objects == 1 ) { |
|
34
|
0
|
|
|
|
|
|
$callback->( $objects[0], undef, At::Error->new( message => 'Incomplete firehose message', fatal => 0 ) ); |
|
35
|
|
|
|
|
|
|
} |
|
36
|
|
|
|
|
|
|
} |
|
37
|
|
|
|
|
|
|
catch ($e) { |
|
38
|
0
|
|
|
|
|
|
$callback->( undef, undef, At::Error->new( message => "Firehose decode failed: $e", fatal => 0 ) ); |
|
39
|
|
|
|
|
|
|
} |
|
40
|
|
|
|
|
|
|
} |
|
41
|
|
|
|
|
|
|
); |
|
42
|
|
|
|
|
|
|
} |
|
43
|
|
|
|
|
|
|
} |
|
44
|
|
|
|
|
|
|
1; |
|
45
|
|
|
|
|
|
|
__END__ |