… | |
… | |
52 | |
52 | |
53 | Initially, nodes are either private (single-process only) or hidden |
53 | Initially, nodes are either private (single-process only) or hidden |
54 | (connected to a master node only). Only when they epxlicitly "become |
54 | (connected to a master node only). Only when they epxlicitly "become |
55 | public" can you send them messages from unrelated other nodes. |
55 | public" can you send them messages from unrelated other nodes. |
56 | |
56 | |
57 | =item noderef - C<host:port,host:port...>, C<id@noderef, C<id> |
57 | =item noderef - C<host:port,host:port...>, C<id@noderef>, C<id> |
58 | |
58 | |
59 | A noderef is a string that either uniquely identifies a given node (for |
59 | A noderef is a string that either uniquely identifies a given node (for |
60 | private and hidden nodes), or contains a recipe on how to reach a given |
60 | private and hidden nodes), or contains a recipe on how to reach a given |
61 | node (for public nodes). |
61 | node (for public nodes). |
62 | |
62 | |
… | |
… | |
366 | |
366 | |
367 | =back |
367 | =back |
368 | |
368 | |
369 | =head1 NODE MESSAGES |
369 | =head1 NODE MESSAGES |
370 | |
370 | |
371 | Nodes understand the following messages sent to them: |
371 | Nodes understand the following messages sent to them. Many of them take |
|
|
372 | arguments called C<@reply>, which will simply be used to compose a reply |
|
|
373 | message - C<$reply[0]> is the port to reply to, C<$reply[1]> the type and |
|
|
374 | the remaining arguments are simply the message data. |
372 | |
375 | |
373 | =over 4 |
376 | =over 4 |
374 | |
377 | |
375 | =cut |
378 | =cut |
376 | |
379 | |
… | |
… | |
400 | rcv "", relay => \&snd; |
403 | rcv "", relay => \&snd; |
401 | |
404 | |
402 | =item eval => $string[ @reply] |
405 | =item eval => $string[ @reply] |
403 | |
406 | |
404 | Evaluates the given string. If C<@reply> is given, then a message of the |
407 | Evaluates the given string. If C<@reply> is given, then a message of the |
405 | form C<@reply, $@, @evalres> is sent (C<$reply[0]> is the port to reply to). |
408 | form C<@reply, $@, @evalres> is sent. |
|
|
409 | |
|
|
410 | Example: crash another node. |
|
|
411 | |
|
|
412 | snd $othernode, eval => "exit"; |
406 | |
413 | |
407 | =cut |
414 | =cut |
408 | |
415 | |
409 | rcv "", eval => sub { |
416 | rcv "", eval => sub { |
410 | my (undef, $string, @reply) = @_; |
417 | my (undef, $string, @reply) = @_; |
… | |
… | |
414 | |
421 | |
415 | =item time => @reply |
422 | =item time => @reply |
416 | |
423 | |
417 | Replies the the current node time to C<@reply>. |
424 | Replies the the current node time to C<@reply>. |
418 | |
425 | |
|
|
426 | Example: tell the current node to send the current time to C<$myport> in a |
|
|
427 | C<timereply> message. |
|
|
428 | |
|
|
429 | snd $NODE, time => $myport, timereply => 1, 2; |
|
|
430 | # => snd $myport, timereply => 1, 2, <time> |
|
|
431 | |
419 | =cut |
432 | =cut |
420 | |
433 | |
421 | rcv "", time => sub { shift; snd @_, AE::time }; |
434 | rcv "", time => sub { shift; snd @_, AE::time }; |
422 | |
435 | |
423 | =back |
436 | =back |