Help with Concurrency

Marc Schütz via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Nov 4 04:09:18 PST 2015


On Tuesday, 3 November 2015 at 23:16:59 UTC, bertg wrote:
>         while (true) {
>             writeln("receiving...");
>             std.concurrency.receive(
>                 (string msg) {
>                     writeln("conn: received ws message: " ~ 
> msg);
>                 }
>             );
>             writeln("received!");
>         }
>     }
> }
> void handleConnectionWebSocket(std.concurrency.Tid caller, 
> shared WebSocket ws)
> {
>     auto sock = cast(WebSocket) ws;
>     while (sock.connected) {
>         writeln("sock in");
>         auto msgIn = sock.receiveText();
>         std.concurrency.send(caller, msgIn);
>     }
> }

What is the type of `msgIn`? Try inserting `pragma(msg, 
typeof(msgIn))` after the line where it's declared and look at 
the compiler's output. My suspicion is that it's something like 
`char[]` or `const(char)[]`, which doesn't match the `string` 
(aka `immutable(char)[]`) you're trying to receive.


More information about the Digitalmars-d-learn mailing list