Re: channel server context of a POE::IRC session?

2002-08-03 Thread Rocco Caputo

On Sat, Aug 03, 2002 at 04:20:18PM +0200, Bruno Boettcher wrote:
 Hello,
 
   funny enough the given wrappers implement more or less what i already
   forgrammed, and they don't seem to solve the multiserver clashing of
   the POE::IRC module (at least my testscript copletely looses track
   when connected to 2 servers...)
 
   anyway the actual problem is, can retrieve from the session or the
   kernel the actual channel context i am in?

The standard $_[SENDER] parameter will be a reference to the IRC
component that generated the event.  You can use it as a destination
in a post() call:

  $kernel-post($sender, ...);

You can also use the sender as a key in the heap.  POE will eat
stringified senders as well as true references, too.

  $heap-{users}{$sender}{$nick} = $userhost;  # or something

It's better to work with session IDs here, though.

  my $irc_id = $_[SENDER]-ID();
  $heap-{users}{$irc_id}{$nick} = $userhost;  # or something

They are not blessed references, so they don't confound Perl's garbage
collection (which POE relies on heavily).  They are also unique,
whereas references may be reused frequently.

-- Rocco Caputo / [EMAIL PROTECTED] / poe.perl.org / poe.sf.net



Re: channel server context of a POE::IRC session?

2002-08-03 Thread Dennis Taylor

On Sat, Aug 03, 2002 at 04:20:18PM +0200, Bruno Boettcher wrote:

 funny enough the given wrappers implement more or less what i already
 forgrammed, and they don't seem to solve the multiserver clashing of
 the POE::IRC module (at least my testscript copletely looses track
 when connected to 2 servers...)

I must confess that I'm not sure what the issue here is. You'll
need two POE::Component::IRC sessions, one for each server, and you can
use the $_[SENDER] field of the states they send to see which server a
given event came from. All channel-specific events have an argument
containing the name of the channel they were generated on. This should
be enough to pinpoint any given event to a server/channel combination,
right?

_
Dennis Taylor   Anyone whose days are all the same and free from
[EMAIL PROTECTED]want inhabits eternity of a sort.  - Peter Hoeg
_
   PGP Fingerprint: A40B 4A41 F140 9196 C598  B096 5324 F39E 42F9 9A11