ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/AnyEvent-MP/MP/Intro.pod
(Generate patch)

Comparing AnyEvent-MP/MP/Intro.pod (file contents):
Revision 1.18 by elmex, Fri Aug 28 14:43:53 2009 UTC vs.
Revision 1.19 by elmex, Fri Aug 28 15:24:16 2009 UTC

248 N3--N4--- | 248 N3--N4--- |
249 \________/ 249 \________/
250 250
251Finished. C<N5> is now happily connected to the rest of the network. 251Finished. C<N5> is now happily connected to the rest of the network.
252 252
253=head3 Setting Up The Profiles
254
255Ok, so much to the profile. Now lets setup the C<eg_simple_receiver> I<profile>
256for later. For the receiver we just give the receiver a I<bind>:
257
258 aemp profile eg_simple_receiver setbinds localhost:12266
259
260And while we are at it, just setup the I<profile> for the sender in the second
261part of this example too. We will call the sender I<profile>
262C<eg_simple_sender>. For the sender we will just setup a I<seed> to the
263receiver:
264
265 aemp profile eg_simple_sender setseeds localhost:12266
266
267You might wonder why we don't setup a I<bind> here. Well, there can be
268exceptions to the I<fully> in the I<fully connected mesh> in L<AnyEvent::MP>.
269If you don't configure a I<bind> for a node's profile it won't bind itself
270somewhere. These kinds of I<nodes> will not be able to send messages to other
271I<nodes> that also didn't I<bind> them self to some TCP address. For this
272example, as well as some cases in the real world, we can live with this
273limitation.
274
275=head3 Registering The Receiver
276
277Ok, where were we. We now discussed the basic purpose of L<AnyEvent::MP::Global>
278and initialise_node with it's relations to profiles. We also setup our profiles
279for later use and now have to continue talking about the receiver example.
280
281Lets look at the next undiscussed line(s) of code:
282
283 my $port = port;
284 AnyEvent::MP::Global::register $port, "eg_receivers";
285
286The C<port> function already has been discussed. It just creates a new I<port>
287and gives us the I<port id>. Now to the C<register> function of
288L<AnyEvent::MP::Global>: The first argument is a I<port id> that we want to add
289to a I<global group>, and it's second argument is the name of that I<global
290group>.
291
292You can choose that name of such a I<global group> freely, and it's purpose is
293to store a set of I<port ids>. That set is made available throughout the whole
294L<AnyEvent::MP> network, so that each node can see which ports belong to that
295group.
296
297The sender will later look for the ports in that I<global group> and send
298messages to them.
299
300Last step in the example is to setup a receiver callback for those messages
301like we have discussed in the first example. We again match for the I<tag>
302C<test>. The difference is just that we don't end the application after
303receiving the first message. We just infinitely continue to look out for new
304messages.
305
253=head1 The Chat Client 306=head1 The Chat Client
254 307
255OK, lets start by implementing the "frontend" of the client. We will 308OK, lets start by implementing the "frontend" of the client. We will
256develop the client first and postpone the server for later, as the most 309develop the client first and postpone the server for later, as the most
257complex things actually happen in the client. 310complex things actually happen in the client.

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines