Permalink
Browse files

making tcp work again

  • Loading branch information...
zpmorgan committed Jul 23, 2011
1 parent 8e8c470 commit 1530a24ae82c70dbaf7340cc609c590d02ced286
Showing with 14 additions and 4 deletions.
  1. +0 −1 lib/Games/VoxEngine/Client.pm
  2. +2 −2 lib/Games/VoxEngine/Launcher.pm
  3. +12 −1 lib/Games/VoxEngine/Server.pm
@@ -161,7 +161,6 @@ sub is_connected{
sub start {
my ($self) = @_;
- $self->send_server({cmd => "BLAH BLAH BLAH BLAH", foo=>"BLAH BLAH BLAH"});
$self->_cv->recv;
}
@@ -106,7 +106,7 @@ sub start_server {
$self->server_up(1);
}
else { #this is child. so run server.
- vox_enable_log_categories ('info', 'error', 'warn');
+ vox_enable_log_categories (qw'network info error warn');
Games::VoxEngine::Debug::init ("server");
my $server = eval { Games::VoxEngine::Server->new(
@@ -131,7 +131,7 @@ sub start_client{
}
else { #this is child. so run client.
- vox_enable_log_categories ('info', 'error', 'warn');
+ vox_enable_log_categories (qw/network info error warn/);
Games::VoxEngine::Debug::init ("client");
my $client = eval { Games::VoxEngine::Client->new (
auto_login => $self->login_name,
@@ -187,12 +187,23 @@ sub tcp_listen{
$hdl->destroy;
$self->client_disconnected ($cid, "error: $msg");
},
+ on_read => sub{
+ my $hdl = shift;
+ vox_log (debug => "on_read: $hdl->{rbuf}");
+ $hdl->push_read( packstring => 'N', sub{
+ my ($handle,$string) = @_;
+ vox_log (debug => "data: $string");
+ $self->handle_protocol($cid,$string);
+ return 1;
+ });
+ return 0; #leave the read buffer.
+ },
);
#sockets are bidirectional. use same handle for in & out.
$self->{clients}->{$cid}{out} = $hdl;
$self->{clients}->{$cid}{in} = $hdl;
$self->client_connected ($cid);
- $self->handle_protocol ($cid);
+ # $self->handle_protocol ($cid);
};
vox_log (info => "Listening for clients on port %d", $self->port);

0 comments on commit 1530a24

Please sign in to comment.