I'm using the XMLRPC Frontier::Daemon module which uses IO::Socket as one of it's base classes. My problem is that when I create a method for the Daemon, the sub does not appear to have an object reference (commonly set to $self or $this) as the first parameter passed. I do pass 2 paramters and they are the only ones being received by the sub. Don't ALL object methods have the object reference passed as the first parameter?
I need to acquire the $self so that I can access one of the base class methods ( connected() which is in IO::Socket ).
Strictly speaking Frontier::Daemon is a subclass of HTTP::Daemon, which is a subclass of IO::Socket::INET which is built upon IO::Socket. Sample code:
use Frontier::Daemon my $id = Frontier::Daemon->new( methods => { sum => \&sum, }, LocalAddr => '127.0.0.1', LocalPort => 80, Reuse => 1, ) or die ("Cannot start RCP daemon: $!"); sub sum { my $self = shift; # This is getting arg1 not the object reference! my $arg1 = shift; # This is getting arg2. my $arg2 = shift; ... }
Everything I read about object methods indicates that all methods should always receive the object reference as the first parameter. (Which is even discarded in most cases because it is not really needed.) But the CPAN documentation for the Frontier::Daemon (with accompanying examples) neglect to extract the reference in the object methods. Why is this server class object different from all others?
The server itself is working fine and does everything it is supposed to. I just need to give it some extra functionality and for that I need access to some class methods.
Not that it should make a difference, but the call to the Daemon constructor does not return (as it was designed this way by the module designer.)
thanks..
In reply to Missing object reference in sub by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |