Index: TCP.pm
===================================================================
RCS file: /cvsroot/poe/poe/POE/Component/Client/TCP.pm,v
retrieving revision 1.24
diff -u -r1.24 TCP.pm
--- TCP.pm	1 Nov 2002 14:59:15 -0000	1.24
+++ TCP.pm	24 Nov 2002 01:09:40 -0000
@@ -47,9 +47,12 @@
   my $bind_address = delete $param{BindAddress};
   my $bind_port    = delete $param{BindPort};
   my $ctimeout     = delete $param{ConnectTimeout};
+  my $args         = delete $param{Args};
+  
+  $args = [] unless defined $args;
 
   foreach ( qw( Connected ConnectError Disconnected ServerInput
-                ServerError ServerFlushed
+                ServerError ServerFlushed Start
               )
           ) {
     croak "$_ must be a coderef"
@@ -62,6 +65,7 @@
   my $input_callback      = delete $param{ServerInput};
   my $error_callback      = delete $param{ServerError};
   my $flush_callback      = delete $param{ServerFlushed};
+  my $start_callback      = delete $param{Start};
   my $filter              = delete $param{Filter};
 
   # Extra states.
@@ -106,6 +110,7 @@
   $disc_callback  = sub {} unless defined $disc_callback;
   $conn_callback  = sub {} unless defined $conn_callback;
   $flush_callback = sub {} unless defined $flush_callback;
+  $start_callback = sub {} unless defined $start_callback;
 
   # Spawn the session that makes the connection and then interacts
   # with what was connected to.
@@ -117,6 +122,7 @@
           $heap->{shutdown_on_error} = 1;
           $kernel->alias_set( $alias ) if defined $alias;
           $kernel->yield( 'reconnect' );
+          $start_callback->( @_ );
         },
 
         # To quiet ASSERT_STATES.
@@ -232,6 +238,8 @@
         %$inline_states,
       },
 
+      args => $args,
+
       # User supplied states.
       package_states => $package_states,
       object_states  => $object_states,
@@ -288,6 +296,8 @@
       Domain         => AF_INET,     # Optional.
       ConnectTimeout => 5,           # Seconds; optional.
 
+      Start          => \&handle_start,
+
       Connected      => \&handle_connect,
       ConnectError   => \&handle_connect_error,
       Disconnected   => \&handle_disconnect,
@@ -298,6 +308,8 @@
 
       Filter         => "POE::Filter::Something",
 
+      Args           => [ 1, 'a', { a => 'b' } ],
+
       InlineStates   => { ... },
       PackageStates  => [ ... ],
       ObjectStates   => [ ... ],
@@ -305,6 +317,14 @@
 
   # Sample callbacks.
 
+  sub handle_start {
+    my ($heap, $num, $str, $hash) = @_[HEAP, ARG0..$#_];
+
+    $heap->{num} = $num;
+    $heap->{str} = $str;
+    $heap->{hash} = $hash;
+  }
+
   sub handle_connect {
     my ($socket, $peer_address, $peer_port) = @_[ARG0, ARG1, ARG2];
   }
@@ -366,6 +386,11 @@
 Alias is to allow a client component to receive "shutdown" and
 "reconnect" events from a user interface session.
 
+=item Args
+
+Requires a LISTREF. It is passed to the optional Start callback, allowing you
+to pass to the created session extra information.
+
 =item BindAddress
 
 =item BindPort
@@ -517,6 +542,14 @@
 
 The ServerInput function will stop being called when $heap->{shutdown}
 is true.
+
+=item Start
+
+Start is an optional callback. It is called at the end of the
+initialization event.
+
+IF you used the Args item, those arguments are available as parameters
+to these callback.
 
 =back
 
