3 # This is class level cell with no constructor or alias registration.
4 # It has two command message handlers, one to get the name and one to set it.
10 return "Hello world from $name\n";
15 my ( $self, $msg ) = @_ ;
17 my $data = $msg->data() ;
27 =head1 Stem Cookbook - World2
31 World2 - A minimal class level B<Stem> cell with read/write data.
35 This B<Stem> class level cell is an extension of the World1 class. It
36 still has a method named C<world_cmd> that will return the stored
37 name. The C<name_cmd> method takes a message and set the $name to its
42 The following code snippet in the F<World2> class
43 cell is the method that will receive a hello command from a
50 return "Hello world!\n";
53 B<Stem> makes the creation of Command message handling methods very
54 I<easy>. Any return with defined data will automatically be sent back
55 to the sender of this command in a response type message. In the
56 method above we return the "Hello world!\n" string which will get printed on
59 For more information on how a message is routed to its destination
60 cell in B<Stem> please see the F<Stem Messaging Design Notes>.
62 =head1 THE CONFIGURATION FILE
64 The following B<Stem> configuration file is used to bring a
65 World2 class level cell into existance in the B<Stem> environment.
68 class => 'Stem::Console',
74 The first entry is C<Stem::Console>, class level cell allows a user to
75 manually send command messages into the B<Stem> system. It is not
76 required for this module, but it is used in this example to send
77 messages to the World2 class and to print responses from it. The
78 second entry loads the C<World2> class. We can now refer to this class
79 cell as I<World2> when we want to send it a message.
83 Execute C<run_stem world> from the command line to run this configuration.
84 You will be greeted with the B<StemE<gt>> prompt. It is now
85 possible to send a message manually to I<World2>. Type the following
86 command at the B<Stem> prompt:
90 This is standard B<Stem> Console syntax, the cell address followed by
91 the command name. This will send a message world_cmd method in the
92 C<World2> class cell. That method returns a value, which is converted
93 into a response message addressed to Stem::Console (the originator of
94 the command message), and its data will be printed on the console terminal.
100 F<Stem Cookbook Part 2>
102 F<Stem Cookbook Part 3>