diff options
| author | Darkelarious <darkelarious@333networks.com> | 2017-05-13 14:18:28 +0200 |
|---|---|---|
| committer | Darkelarious <darkelarious@333networks.com> | 2017-05-13 14:20:49 +0200 |
| commit | 34a2c7390ea9662d33258d384e72fff1912343ff (patch) | |
| tree | d96ea33c0107e4906a152aa1de4b5c75b81ba0a8 /lib/MasterServer/UDP/BeaconChecker.pm | |
| parent | 84af66aba26d2088d5d95c240d176f3edaf17b58 (diff) | |
| download | MasterServer-Perl-34a2c7390ea9662d33258d384e72fff1912343ff.tar.gz MasterServer-Perl-34a2c7390ea9662d33258d384e72fff1912343ff.zip | |
revised synchronization methods, config settings and bug fixesv2.3.0
Diffstat (limited to 'lib/MasterServer/UDP/BeaconChecker.pm')
| -rwxr-xr-x | lib/MasterServer/UDP/BeaconChecker.pm | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/lib/MasterServer/UDP/BeaconChecker.pm b/lib/MasterServer/UDP/BeaconChecker.pm index f74378d..73220cf 100755 --- a/lib/MasterServer/UDP/BeaconChecker.pm +++ b/lib/MasterServer/UDP/BeaconChecker.pm @@ -1,4 +1,3 @@ - package MasterServer::UDP::BeaconChecker; use strict; @@ -6,7 +5,7 @@ use warnings; use AnyEvent::Handle::UDP; use Exporter 'import'; -our @EXPORT = qw| query_udp_server|; +our @EXPORT = qw| query_udp_server |; ################################################################################ ## Get the server status from any server over UDP and store the received @@ -17,20 +16,28 @@ sub query_udp_server { my ($self, $id, $ip, $port, $secure, $message_type) = @_; my $buf = ""; - # debug spamming - $self->log("udp", "Query server $id ($ip:$port)"); + # debug logging + # $self->log("debug", "Query server $id ($ip:$port)"); # connect with UDP server my $udp_client; $udp_client = AnyEvent::Handle::UDP->new( - # Bind to this host and port connect => [$ip, $port], - timeout => 1, - on_timeout => sub {$udp_client->destroy();}, # don't bother reporting timeouts + timeout => $self->{timeout_time}, + on_timeout => sub {$udp_client->destroy();}, # do not report timeouts on_error => sub {$udp_client->destroy();}, # or errors - on_recv => sub { + on_recv => sub { # add packet to buffer $buf .= $_[0]; + + # FIXME: note to self: order is important when having combined queries! + # TODO: find a more elegant and long-time solution for this. + + # message type 1: \basic\\secure\wookie + # if validate, assume that we sent a \basic\secure request. + if ($buf =~ m/\\validate\\/){ + $self->process_udp_validate($buf, $ip, undef, $port); + } # message type 0: \basic\\info\ # if gamename, ver, hostname and hostport are available, but NOT the value @@ -42,12 +49,6 @@ sub query_udp_server { $self->process_query_response($buf, $ip, $port); } - # message type 1: \basic\\secure\wookie - # if validate, assume that we sent a \basic\secure request. - if ($buf =~ m/\\validate\\/){ - $self->process_udp_validate($buf, $ip, undef, $port); - } - # message type 2: \status\ # contains same info as \basic\\info, but also "listenserver". Only for UT. if ($buf =~ m/\\gamename\\ut/ && |
