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.32 by root, Mon Aug 31 13:46:31 2009 UTC vs.
Revision 1.33 by root, Mon Aug 31 15:12:49 2009 UTC

762 aemp run profile seed 762 aemp run profile seed
763 763
764And then you can experiment with chatting, killing one or more clients, or 764And then you can experiment with chatting, killing one or more clients, or
765stopping and restarting the server, to see the monitoring in action. 765stopping and restarting the server, to see the monitoring in action.
766 766
767The crucial point you should understand from this example is that
768monitoring is usually symmetric: when you monitor some other port,
769potentially on another node, that other port usually should monitor you,
770too, so when the connection dies, both ports get killed, or at least both
771sides can take corrective action. Exceptions are "servers" that serve
772multiple clients at once and might only wish to clean up, and supervisors,
773who of course should not normally get killed (unless they, too, have a
774supervisor).
775
776If you often think in object-oriented terms, then treat a port as an
777object, C<port> is the constructor, the receive callbacks set by C<rcv>
778act as methods, the C<kil> function becomes the explicit destructor and
779C<mon> installs a destructor hook. Unlike conventional object oriented
780programming, it can make sense to exchange ports more freely (for example,
781to monitor one port from another).
782
767There is ample room for improvement: the server should probably remember 783There is ample room for improvement: the server should probably remember
768the nickname in the C<join> handler instead of expecting it in every chat 784the nickname in the C<join> handler instead of expecting it in every chat
769message, it should probably monitor itself, and the client should not try 785message, it should probably monitor itself, and the client should not try
770to send any messages unless a server is actually connected. 786to send any messages unless a server is actually connected.
771 787

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines