cleaned up demo scripts locations
[urisagit/Stem.git] / Cookbook / World1.pm
CommitLineData
4536f655 1package World1;
2
3# This is class level cell with no constructor or alias registration.
4# It has one simple command message handler
5
6sub hello_cmd {
7
8 return "Hello world!\n";
9}
10
11=head1 Stem Cookbook - World1
12
13=head1 NAME
14
15World1 - A minimal class level B<Stem> cell.
16
17=head1 DESCRIPTION
18
19This is the simplest possible B<Stem> class level cell. It contains a
20single method named C<world_cmd>. Because this method ends in C<_cmd>
21it is capable of being invoked remotely via a command message and have
22its return value sent back as a response message to the sender, which
23in this example is the Stem::Console cell.
24
25=head2 COMMAND METHOD
26
27The following code snippet in the F<World1> class cell is the method
28that will receive a hello command from a remote sender.
29
30 package World1;
31
32 sub hello_cmd {
33
34 return "Hello world!\n";
35 }
36
37B<Stem> makes the creation of Command message handling methods very
38I<easy>. Any return with defined data will automatically be sent back
39to the sender of this command in a response type message. In the
40method above we return the "Hello world!\n" string which will get printed on
41the console.
42
43For more information on how a message is routed to its destination
44cell in B<Stem> please see the F<Stem Messaging Design Notes>.
45
46=head1 THE CONFIGURATION FILE
47
48The following B<Stem> configuration file is used to bring a
49World1 class level cell into existance in the B<Stem> environment.
50
51-
52 class: Stem::Console
53-
54 class: World1
55
56The first entry is C<Stem::Console>, a class level cell allows a user
57to manually send command messages into the B<Stem> system. It is not
58required for this module, but it is used in this example to send
59messages to the World1 class and to print responses from it. The
60second entry loads the C<World1> class. We can now refer to this class
61cell as I<World1> when we want to send it a message.
62
63=head1 USAGE
64
65Execute C<run_stem world> from the command line to run this configuration.
66You will be greeted with the B<StemE<gt>> prompt. It is now
67possible to send a message manually to I<World1>. Type the following
68command at the B<Stem> prompt:
69
70B<World1 hello>
71
72This is standard B<Stem> Console syntax, the cell address followed by
73the command name. This will send a message world_cmd method in the
74C<World1> class cell. That method returns a value, which is converted
75into a response message addressed to Stem::Console (the originator of
76the command message), and its data will be printed on the console terminal.
77
78B<"Hello world!">
79
80=cut
81
821 ;