Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
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..
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Missing object reference in sub
by chromatic (Archbishop) on Sep 26, 2007 at 18:37 UTC | |
by Lazarus (Novice) on Sep 26, 2007 at 20:13 UTC | |
by chromatic (Archbishop) on Sep 26, 2007 at 20:49 UTC | |
by almut (Canon) on Sep 26, 2007 at 21:10 UTC | |
by chromatic (Archbishop) on Sep 26, 2007 at 23:09 UTC | |
by Lazarus (Novice) on Sep 28, 2007 at 13:55 UTC | |
by almut (Canon) on Sep 26, 2007 at 20:46 UTC | |
by Lazarus (Novice) on Sep 28, 2007 at 14:04 UTC | |
by kyle (Abbot) on Sep 26, 2007 at 21:38 UTC | |
by almut (Canon) on Sep 26, 2007 at 22:10 UTC | |
|
Re: Missing object reference in sub
by naikonta (Curate) on Sep 26, 2007 at 18:48 UTC |