Chat server: Difference between revisions
Content added Content deleted
(Remove weird comment from task description) |
(→{{header|Perl 6}}: replace no longer relevant template with different template; add some notes below the code) |
||
Line 1,482: | Line 1,482: | ||
=={{header|Perl 6}}== |
=={{header|Perl 6}}== |
||
<div style="display:inline-block">{{trans|Python}}</div> (or at least started out that way) |
|||
{{improve|Perl 6| |
|||
* I'm not sure if the writes to <tt>%connections</tt> and <tt>$name</tt> can cause race conditions, as I don't understand the <tt>react</tt>/<tt>whenever</tt> idiom well enough yet. |
|||
* When a client sends bytes that are not valid UTF8, the server dies with "<code>Unhandled exception: Malformed UTF-8</code>" and I can't seem to find a way to prevent it. |
|||
}} |
|||
{{trans|Python}} |
|||
{{works with|Rakudo|2016.07}} |
{{works with|Rakudo|2016.07}} |
||
<lang perl6>#!/usr/bin/env perl6 |
<lang perl6>#!/usr/bin/env perl6 |
||
Line 1,528: | Line 1,523: | ||
} |
} |
||
}</lang> |
}</lang> |
||
Notes: |
|||
* It operates asynchronously (using <tt>IO::Socket::Async</tt>), so a slow connection to one client won't affect other clients. |
|||
* It accepts messages encoded in UTF-8. |
|||
* It tokenizes the message streams at newline boundaries (using the <tt>Supply.lines</tt> method), which I think makes the most sense for a chat application. |
|||
{{todo|Perl 6|2=Once »[https://rt.perl.org/Ticket/Display.html?id=128862 this Rakudo bug]« is resolved, make sure to catch UTF8-invalid messages.}} |
|||
=={{header|PicoLisp}}== |
=={{header|PicoLisp}}== |