… | |
… | |
349 | |
349 | |
350 | AnyEvent->condvar->recv; |
350 | AnyEvent->condvar->recv; |
351 | |
351 | |
352 | This is all. Looks much easier, doesn't it? I'll explain it only shortly, as |
352 | This is all. Looks much easier, doesn't it? I'll explain it only shortly, as |
353 | we had the discussion of the C<rcv> method in the client part of this tutorial |
353 | we had the discussion of the C<rcv> method in the client part of this tutorial |
|
|
354 | above. |
|
|
355 | |
|
|
356 | First this: |
|
|
357 | |
|
|
358 | become_public "localhost:1299"; |
|
|
359 | |
|
|
360 | This will tell our I<node> to become a I<public> node, which means that it can |
|
|
361 | be contacted via TCP. The first argument should be the I<noderef> the server |
|
|
362 | wants to be reachable at. In this case it's the TCP port 1299 on localhost. |
|
|
363 | |
354 | above. We bascially setup two receivers, one for the C<join> messages and |
364 | Next we bascially setup two receivers, one for the C<join> messages and |
355 | another one for the actual messages of type C<messsage>. |
365 | another one for the actual messages of type C<messsage>. |
356 | |
366 | |
357 | In the C<join> message we get the client's port, which we just remember in the |
367 | In the C<join> message we get the client's port, which we just remember in the |
358 | C<%client_ports> hash. In the receiver for the message type C<message> we will |
368 | C<%client_ports> hash. In the receiver for the message type C<message> we will |
359 | just iterate through all known C<%client_ports> and relay the message to them. |
369 | just iterate through all known C<%client_ports> and relay the message to them. |
|
|
370 | |
|
|
371 | And thats it. |
360 | |
372 | |
361 | =head2 The Remaining Problems |
373 | =head2 The Remaining Problems |
362 | |
374 | |
363 | The shown implementation still has some bugs. For instance: How does the |
375 | The shown implementation still has some bugs. For instance: How does the |
364 | server know that the client isn't there anymore, and can cleanup the |
376 | server know that the client isn't there anymore, and can cleanup the |