Am 22.10.2013 01:39, schrieb Shammah Chancellor:
On 2013-10-21 14:19:56 +0000, James Pike said:
In this instance I'm running a chat-like server where users can play
and chat together, so for example when one websocket receives a
message, the fibre that receives the message might then go off and
send that message to other web sockets.Is it fine to do this or do I need some kinda Task Mutex around the
"send" call?Thanks!
You need to send a message to the other thread to pass along. I am
doing something similar:https://github.com/schancel/gameserver
This is what I would recommend, too (i.e. to use vibe.core.concurrency.send
/recv
to send the messages to a dedicated
sender task for each client). This has the advantage that if a single
client has a low quality connection, the other clients will stay unaffected.
Without doing this, you currently do need to use a TaskMutex
to
protect writes from different tasks. This requirement may fall at some
point when WebSocket connections get their own internal mutex, but this
is not yet completely decided.