Skip to content

Commit 5e69a47

Browse files
committed
use enum instead of constant and rename $type to $packet-type
1 parent ecc1ed8 commit 5e69a47

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

lib/Net/RCON.pm6

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ unit class Net::RCON;
22

33
use experimental :pack;
44

5-
constant {
6-
SERVERDATA_RESPONSE_VALUE => 0,
7-
SERVERDATA_AUTH_RESPONSE => 2,
8-
SERVERDATA_EXECCOMMAND => 2,
9-
SERVERDATA_AUTH => 3
10-
};
5+
enum SERVERDATA (
6+
RESPONSE_VALUE => 0,
7+
AUTH_RESPONSE => 2,
8+
EXECCOMMAND => 2,
9+
AUTH => 3,
10+
);
1111

1212
sub connect(:$hostname, :$port, :$password) {
1313

@@ -24,15 +24,15 @@ sub connect(:$hostname, :$port, :$password) {
2424

2525
sub authenticate(:$connection, :$password) {
2626

27-
my $type = SERVERDATA_AUTH;
27+
my $packet-type = SERVERDATA::AUTH;
2828
my $data = $password;
2929

30-
send(:$connection, :$type, :$data);
30+
send(:$connection, :$packet-type, :$data);
3131
}
3232

33-
sub send(:$connection, :$type, :$data) {
33+
sub send(:$connection, :$packet-type, :$data) {
3434

35-
my $payload = pack("VV", 1, $type) ~ $data ~ pack("xx");
35+
my $payload = pack("VV", 1, $packet-type) ~ $data ~ pack("xx");
3636
$payload = pack("V", $payload.bytes) ~ $payload;
3737

3838
$connection.write($payload);

0 commit comments

Comments
 (0)