public void PushClusterState(ClusterEvent.CurrentClusterState clusterState, Address currentClusterAddress)
        {
            // Push ClusterState x to subscribed client.
            // So if client A subscibes to ClusterState A then it should only get A and not B.
            // TODO:
            
            List<ClusterRoleLeader> clusterRoleLeaders = new List<ClusterRoleLeader>();
            foreach (var member in clusterState.Members)
            {
                var role = member.Roles.First();
                var address = clusterState.RoleLeader(role);
                clusterRoleLeaders.Add(new ClusterRoleLeader(role, address));
            }

            var context = GlobalHost.ConnectionManager.GetHubContext<ClusterStateHub>();
            dynamic allClients = context.Clients.All.broadcastClusterState(clusterState, clusterRoleLeaders, currentClusterAddress);
        }
Ejemplo n.º 2
0
        public void ClusterState(ClusterEvent.CurrentClusterState clusterState, Address currentClusterAddress)
        {
            List<ClusterRoleLeader> clusterRoleLeaders = new List<ClusterRoleLeader>();
            foreach (var member in clusterState.Members)
            {
                foreach (var role in member.Roles)
                {
                    var address = clusterState.RoleLeader(role);
                    clusterRoleLeaders.Add(new ClusterRoleLeader(role, address));
                }
            }

            var context = GlobalHost.ConnectionManager.GetHubContext<MonitorHub>();
            context.Clients.All.broadcastClusterState(new
            {
                state = clusterState,
                leaders = clusterRoleLeaders,
                address = currentClusterAddress,
                time = DateTime.UtcNow
            });
        }