Пример #1
0
        public async Task PropagateChange(EmergencyObjectMessage data)
        {
            var access = data.header.Access;
            var owner  = data.header.createdBy;

            Parallel.ForEach(activeWebsockets, async(ws) =>
            {
                if (ws.ws.State == WebSocketState.Open)
                {
                    if (ws.endpoint.uid == owner)
                    {
                        /* Owner will receive all data regardless of access control list */
                        var sendObject = data.Copy <EmergencyObjectMessage>();
                        await sendObjectToWebsocket(ws.ws, sendObject);
                    }
                    else
                    {
                        /* Get allowed Paths for this user and reduce object to allowed paths */
                        var paths = objectService.GetAccessPaths(Models.AccessLevelEnum.Read, data, ws.endpoint);
                        if (paths != null && paths.Count > 0)
                        {
                            var sendObject  = data.Copy <EmergencyObjectMessage>();
                            sendObject.data = objectService.RemoveUnallowedPaths <object>(paths, sendObject.data, data.partPath);
                            await sendObjectToWebsocket(ws.ws, sendObject);
                        }
                    }
                }
            });
        }