root/POE-Component-Client-MSN/trunk/sample.pl

Revision 926 (checked in by miyagawa, 17 years ago)

Initial revision

  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
Line 
1 #!/usr/local/bin/perl -w
2 # $Id$
3 #
4 # Tatsuhiko Miyagawa <miyagawa@edge.jp>
5 # EDGE, Co.,Ltd.
6 #
7
8 use strict;
9
10 sub POE::Kernel::ASSERT_DEFAULT { $ENV{POE_ASSERT} || 0 }
11 sub POE::Kernel::TRACE_DEFAULT  { $ENV{POE_TRACE} || 0 }
12 sub POE::Kernel::TRACE_EVENTS   { $ENV{POE_EVENTS} || 0 }
13
14 use POE qw(Component::Client::MSN Component::TSTP);
15
16 my($user, $pw) = @ARGV;
17
18 # for Ctrl-Z
19 POE::Component::TSTP->create();
20
21 # spawn MSN session
22 POE::Component::Client::MSN->spawn(Alias => 'msn');
23
24 POE::Session->create(
25     inline_states =>  {
26         _start => sub {
27             my $kernel = $_[KERNEL];
28             # register your session as MSN observer
29             $kernel->post(msn => 'register');
30             # tell MSN how to connect servers
31             $kernel->post(msn => connect => {
32                 username => $user,
33                 password => $pw,
34             });
35         },
36         msn_goes_online => \&msn_goes_online,
37         msn_signin => \&msn_signin,
38     },
39 );
40
41
42 sub msn_signin {
43     my($status, $account, $screen_name, $email_verified) = @_[ARG0..$#_];
44     warn "online as $screen_name ($account)";
45 }
46
47
48 sub msn_goes_online {
49     my $event = $_[ARG0];
50
51 }
52
53 $poe_kernel->run;
Note: See TracBrowser for help on using the browser.