1 #!/usr/bin/perl -w
 2 
 3 # Invoke: cbServer.pl http://myHost:8080
 4 use Frontier::Daemon;
 5 use Frontier::Client;
 6 use xmlBlaster::Exception ;
 7 use xmlBlaster::XmlBlaster ;
 8 use xmlBlaster::MsgUnit ;
 9 use xmlBlaster::EraseReturnQos ;
10 
11 
12 sub do_update {
13         print "GOT AN UPDATE\n";
14         return "<qos><state>OK</state></qos>";
15 }
16 
17 sub do_ping {
18         print "got ping\n";
19         return "<qos><state>OK</state></qos>";
20 }
21 
22 my $server_url=$ARGV[0];
23 my $local_url="http://127.0.0.1:9091/RPC2";
24 
25 my $server = Frontier::Client->new(url => $server_url);
26 print "Connected to xmlBlaster server on $server_url \n";
27 
28 # Call the remote server and get our result.
29 my $sessionId = $server->call('authenticate.login', "dk2", "dk2",
30                 "<qos><callback type='XMLRPC'>$local_url</callback>".
31                 "<local>false</local></qos>", "");
32 print "\nLogin success with sessionId=$sessionId \n";
33 
34 $server->call('xmlBlaster.subscribe',
35                         $sessionId,
36                         "<key oid='' queryType='XPATH'>//service</key>",
37                         "<qos><duplicateUpdates>false</duplicateUpdates></qos>");
38 
39 
40 print "\nListening for callbacks on $local_url\n";
41 print "\nTry 'perl testpub.pl http://myHost:8080' in another console, you should receive the update here\n";
42 
43 Frontier::Daemon->new(
44             LocalPort => 9091,
45             methods => {
46                         'update'   => \&do_update,
47                         'ping'   => \&do_ping
48             });


syntax highlighted by Code2HTML, v. 0.9.1