On Mon, 22 Oct 2012 17:31:53 GMT, kyubuns wrote:

import vibe.d;

static this()
{
  WebSocket[] client_list;

  auto router = new UrlRouter;
  router.get("/", handleWebSockets(delegate(WebSocket sock){
    client_list ~= sock;
    while( sock.connected ){
      auto msg = sock.receive();
      foreach(client; client_list) client.send(msg); //=>"ERROR: Operating on TcpConnection owned by a different fiber!"
    }
  }));

  auto settings = new HttpServerSettings;
  settings.port = 9998;
  listenHttp(settings, router);
}

I found https://github.com/rejectedsoftware/vibe.d/issues/50
I want to call acquire(), but WebSocket class don't have acquire().
How do you think most simple websocket chat?

If you are prepared to deal with the alpha quality code I'm working on a Socket.IO implementation for vibe.d https://github.com/eldar/socket.io-d/

A simple example is included with the source code (app.d for server and socket.js for client) It supports the callback model of reference implementation for Node, which is somewhat simpler than writing a while() loop. So for a simple chat you will have to listen for the event on the socket and then broadcast it to all the clients using broadcast_emit() function. It's not documented yet so let me know if there are any problems(and there will be many!). I'm currently working on transports other than Websockets, in particular xhr-polling.