Lo,

AxKit2.

Well, I've finally got round to farming out the slow bits of my app.
Atm it's using Net::Server, but I am going to look at gearmand shortly.
Anyway, as it's the first time I've used sockets, could someone have a
look at my first hack and tell me what I'm missing please?
I essentially serialise a hash and the other end sends back xml.

I have a simple xmlresponse hook. It calls various methods in 
the Firstb2b::Acme class, the method I'm testing with is below.
Acme "uses" Firstb2b::AxKit2::SubprocessEvent, which is also below.

Qu:

1) $bbref should be stored somewhere, but where? I presume in the notes
of something. If this is correct, which notes and how do I get them?
I suppose Ax2/Danga somehow maintains a list of watched fds along with a
persitent data structure?

2) What does the callback of addotherfds do? I can't get it to fire.

sub _state_login {
    my Firstb2b::Acme $self = shift;

    $self->{plugin}->log(LOGDEBUG, "\n\nHERE\n\n");

    my $PORT = 2000;

    my $sock = IO::Socket::INET->new(
                                        PeerHost  => 'localhost',
                                        PeerPort  => $PORT,
                                        Proto     => 'tcp',
                                        Type      => SOCK_STREAM,
                                        Blocking  => 0,
                                        )
                or die "Error creating client on port $PORT : [EMAIL 
PROTECTED]";

    IO::Handle::blocking( $sock, 0 );

    my $var = Firstb2b::AxKit2::SubprocessEvent->new($sock);

    $var->watch_read(1);

    my $cb = sub { die
'YAYAYAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'; };
    $var->AddOtherFds( fileno($sock) => $cb );

    $var->write( freeze( { method => 'state_login' } ) . 'ROSE' . EOL );
    #$var->write( 'HELLO' . 'ROSE' . "\015\012" );

    my $dom = $self->get_base_xml(1);
    my $root = $dom->getElementsByTagName('main')->get_node(1);
    $root->setAttribute( 'uri_post', $self->uri_gen( { state => 'start'
} ) );
    return $dom;
}



package Firstb2b::AxKit2::SubprocessEvent;

use base qw(Danga::Socket);

use fields qw(bar);

sub new {
    my Firstb2b::AxKit2::SubprocessEvent $self = shift;
    my $sock = shift;
    $self = fields::new( $self ) unless ref($self);
    $self->SUPER::new($sock);
    return $self;
}

sub event_read {
    my Firstb2b::AxKit2::SubprocessEvent $self = shift;
    my $bref = $self->read(10000);
    return $self->close($!) unless defined $bref;
    chomp $$bref;
    print 'HEREEEEEEEEEEEEEEEEEEEE', $$bref;
    $self->do_stuff;
}

sub do_stuff {

    my Firstb2b::AxKit2::SubprocessEvent $self = shift;
    print "start do_stuff\n";
    print "finish do_stuff\n";
    #$self->close;
}

1;



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to