Hello,

I'm new to POE, so please excuse me if I have missed out on the obvious.....

My goal (eventually) is to write a client application that would send 
information to a server as well as handle information sent to other clients 
on a network. I'm involved in a social psych experiment, where interactions 
will be done through soley through computers.....

I have managed to figure out most of what I need done, however, I am having 
trouble with using Tk with the TCP component. In order to test an application 
I have tinkered around with a sample file which I picked up from Matt 
Sergeant's slide show paper..... His sample works great. My sample, 
however.... Could someone please tell me what's wrong with my code? Or, how I 
may improve upon it.

I'm using WinXp (reluctantly) but also couldn't get it to run in redhat 7.1

Thanks in advance....

Jason

#!/usr/bin/perl

use Tk;
use POE;
use POE::Component::Client::TCP;


# A portion of this code was taken from Matt Sergeant's
# slide show: "Programming POE"
# http://axkit.org/docs/presentations/tpc2002/
# This is modified in an attempt to figure out how to use
# Tk with the TCP Component.

POE::Component::Client::TCP->new
  ( RemoteAddress => "majestic",
    RemotePort => 12345,
    Connected => sub  {
      print "nothing\n";
      my $heap = $_[HEAP];
      $heap->{server}->put("test");
    },

    ServerInput => sub  {
      my $input = $_[ARG0];
      print "$input\n";
    },

    inline_states => {
                      _start => \&startui,
                      ev_count => \&ui_count,
                      ev_clear => \&ui_clear,
                     },
  );

$poe_kernel->run();


sub startui {
  my ($kernel, $session, $heap) = @_[KERNEL, SESSION, HEAP];

  $poe_main_window->Label( -text => 'Counter' )->pack;

  $heap->{counter_widget} =
    $poe_main_window->Label(-textvariable => \$heap->{counter} )->pack;

  $poe_main_window->Button(-text => 'Clear',
                           -command => $session->postback( 'ev_clear' 
))->pack;

  $kernel->yield("ev_count");
}

sub ui_count {
  $_[HEAP]->{counter}++;
  $_[KERNEL]->yield("ev_count");
}

sub ui_clear {
  $_[HEAP]->{counter} = 0;
}




-- 
Jason W. Martinez
Department of Sociology
University of California, Riverside

Reply via email to