Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix poseidon #3912

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions control/poseidon.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ queryserver_port=24390
server_type=Default

debug=0
#debugPacket_exclude=007F, 0360, 0187
31 changes: 14 additions & 17 deletions src/Poseidon/QueryServer.pm
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
###########################################################
# Poseidon server - OpenKore communication channel
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# Copyright (c) 2005-2006 OpenKore Development Team
Expand Down Expand Up @@ -66,8 +66,8 @@ sub process {
$client->close();
return;
}
print "[PoseidonServer]-> Received query from bot client " . $client->getIndex() . "\n";

print "[Poseinon Qery server] <- Received request from OpenKore (" . $client->getIndex() . ")\n";

my %request = (
packet => $args->{packet},
Expand Down Expand Up @@ -95,25 +95,23 @@ sub process {
sub onClientNew {
my ($self, $client, $index) = @_;
$client->{"$CLASS parser"} = new Bus::MessageParser();
print "[PoseidonServer]-> New Bot Client Connected : " . $client->getIndex() . "\n";
print "[Poseinon Qery server] <- OpenKore (" . $client->getIndex() . ") connected.\n";
}

sub onClientExit {
my ($self, $client, $index) = @_;
print "[PoseidonServer]-> Bot Client Disconnected : " . $client->getIndex() . "\n";
print "[Poseinon Qery server] -> OpenKore (" . $client->getIndex() . ") disconnected.\n";
}

sub onClientData
{
sub onClientData {
my ($self, $client, $msg) = @_;
my ($ID, $args);

my $parser = $client->{"$CLASS parser"};

$parser->add($msg);

while ($args = $parser->readNext(\$ID))
{

while ($args = $parser->readNext(\$ID)) {
$self->process($client, $ID, $args);
}
}
Expand All @@ -126,8 +124,7 @@ sub iterate {
$server = $self->{"$CLASS server"};
$queue = $self->{"$CLASS queue"};

if ($server->getState() eq 'requested')
{
if ($server->getState() eq 'requested') {
# Send the response to the client.
if (@{$queue} > 0 && $queue->[0]{client}) {
my ($data, %args);
Expand All @@ -137,12 +134,12 @@ sub iterate {
$data = serialize("Poseidon Reply", \%args);
$queue->[0]{client}->send($data);
$queue->[0]{client}->close();
print "[PoseidonServer]-> Sent result to client : " . $queue->[0]{client}->getIndex() . "\n";
print "[Poseinon Qery server] -> Response sent to OpenKore (" . $queue->[0]{client}->getIndex() . ")\n";
}
shift @{$queue};

} elsif (@{$queue} > 0 && $server->getState() eq 'ready') {
print "[PoseidonServer]-> Querying Ragnarok Online client [" . getFormattedDateShort(time, 1) . "]...\n";
print "[Poseinon Qery server] -> Querying RO client [" . getFormattedDateShort(time, 1) . "] ...\n";
$server->query($queue->[0]{packet});
}
}
Expand Down
Loading
Loading