コード例 #1
0
        public async Task SendMessageAsync(string connectionId, string execAction, object msg)
        {
            var list = await socketClientStorage.GetByConnectionIdAsync(connectionId);

            foreach (var item in list)
            {
                await item.SendMessage(new Object.WebSocketMessageModel
                {
                    message = msg,
                    action  = execAction
                });
            }
        }
コード例 #2
0
        public async Task SendMessageAsync(string groupId, string execAction, object msg)
        {
            //获取所有的连接
            var connections = await groupStorage.GetAsync(groupId);

            if (connections == null || connections.Count() <= 0)
            {
                return;
            }
            //获取所有的socket客户端
            var webSockets = await socketClientStorage.GetByConnectionIdAsync(connections);

            if (webSockets != null && webSockets.Count() > 0)
            {
                Parallel.ForEach(webSockets, async item =>
                {
                    await item.SendMessage(new Object.WebSocketMessageModel
                    {
                        message = msg,
                        action  = execAction
                    });
                });
            }
        }