Hi,
I'm can't figure out why I'm getting the error:
Can't locate object method "put" via package "POE::Wheel::SocketFactory"
(perhaps you forgot to load "POE::Wheel::SocketFactory"?) at
/home/jstrauss/tradestudy/lib/perl/TradeStudy/TWS.pm line 53.
With the code below. The error is occuring in inline_states send_quote
function, at the put
The $heap->{server} is of class:
POE::Wheel::SocketFactory
I've never had this problem before which leads me to believe its, programmer
error, but I can't see it
Thanks
Jay
package TradeStudy::TWS;
use 5.006;
use strict;
use warnings;
use IB::TWS::Contract;
use POE qw(Component::Client::TCP Filter::Reference);
use base qw/Class::Accessor/;
#__PACKAGE__->mk_accessors(qw/last/);
our $VERSION = sprintf "%d.%03d", q$Revision: 1.19 $ =~ /(\d+)/g;
POE::Component::Client::TCP->new(
RemoteAddress => "localhost",
Filter => "POE::Filter::Reference",
RemotePort => 11011,
Alias => "client_connection",
ServerInput => sub {
my $response = $_[ARG0];
my $heap = $_[HEAP];
%{$heap->{return}} = %{$response};
$heap->{transaction} = undef;
${$heap->{flag}} = 0;
},
ServerFlushed => sub {
my $heap = $_[HEAP];
if ($heap->{transaction} eq "quote") {
${$heap->{flag}} = 0;
$heap->{transaction} = undef;
}
},
Disconnected => sub { $_[KERNEL]->yield("reconnect")},
# Handle some custom events.
InlineStates => {
send_quote => sub {
my ($heap, $flag, $security, $returnValue) =
@_[HEAP, ARG0, ARG1, ARG2];
my $contract = IB::TWS::Contract->new({
symbol => $security->symbol,
secType => "STK",
exchange => "SMART"});
$heap->{flag} = $flag;
$heap->{transaction} = "quote";
$heap->{returnValue} = $returnValue;
$heap->{server}->put($contract);
},
do_order => sub {
my ($heap, $flag, $stuff) = @_[HEAP, ARG0, ARG1];
$heap->{server}->put($stuff);
$heap->{flag} = $flag;
$heap->{transaction} = "order";
}
},
);
sub quote {
my ($self, $security) = @_;
my $flag = 1;
my %returnValue;
$poe_kernel->post(client_connection=>'send_quote',
\$flag, $security, \%returnValue);
while ($flag) {
$poe_kernel->run_one_timeslice();
}
print %returnValue,"\n";
}
sub order {
my ($object, $stuff) = @_;
my $flag = 1;
$poe_kernel->post(client_connection=>'do_order', \$flag, $stuff);
while ($flag) {
$poe_kernel->run_one_timeslice();
}
}
1;
__END__