给特定用户的 Websocket 消息
我是 .NET (C#) 和 websockets 的新手...我已经安装了 VS2012 和 Windows Server 2012,并且已经启动并运行了 websockets.我似乎无法做的是从一个套接字接收消息并将其发送到另一个特定的套接字.唯一的选择似乎是将消息广播到所有套接字.有没有办法只将消息定位到特定用户?我希望聊天室版主有机会拒绝不当帖子.
I am new to .NET (C#) and websockets... I have installed VS2012 and Windows Server 2012 and have websockets up and running. What I can't seem to do is receive a message from one socket and send it to another, specific socket. The only option seems to be to broadcast the message to all sockets. Is there a way to target messages to only specific users? I want the chat room moderator to have the chance to reject inappropriate posts.
推荐的方法是设置某种路由方案,以确保可以将消息传递给特定用户.例如.Pubnub 使用通道进行消息路由.为了防止多个连接到您的服务器,您可以考虑将服务器端的通道多路复用到一个套接字中.
The recommended approach is setting up some sort of routing scheme to ensure that a message can be delivered to a specific user. E.g. Pubnub uses channels for message routing. To prevent multiple connections to your server, you could consider multiplexing channels on the server-side into a single socket.
要实施审核,您需要记住一些额外的挑战;考虑将传入的消息放入审核队列以供批准.消息队列,如 ZeroMQ 或 RabbitMQ 可以解决这个问题.版主会从队列中提取消息,然后批准该消息进行最终广播,或者拒绝(将消息丢在地板上).
To implement moderation, you have some additional challenges to keep in mind; Think about placing incoming messages into a moderation queue for approval. A message queue like ZeroMQ or RabbitMQ would work for this. A moderator would pull messages from the queue and either approve the message for final broadcast, or reject (dropping the message on the floor).