private IClientProxy GetRecipients(DrapoPipeAudienceType recipient) { string connectionId = this._requestReader.GetPipeHeaderConnectionId(); if (string.IsNullOrEmpty(connectionId)) { return(null); } DrapoConnection connection = _connectionManager.Get(_requestReader.GetDomain() ?? string.Empty, connectionId); if (connection == null) { return(null); } if (recipient == DrapoPipeAudienceType.Others) { return(this._hub.Clients.GroupExcept(connection.Domain, new List <string>() { connectionId })); } else if (recipient == DrapoPipeAudienceType.Me) { return(this._hub.Clients.Client(connectionId)); } else if (recipient == DrapoPipeAudienceType.Everyone) { return(this._hub.Clients.Group(connection.Domain)); } return(null); }
public bool Check() { bool updated = false; Dictionary <string, bool> containers = new Dictionary <string, bool>(); using (IRedisClient client = _redisManagerPool.GetClient()) { foreach (string key in client.GetKeysByPattern(this.CreateDomainKey(string.Empty) + "*")) { DrapoConnection connection = client.Get <DrapoConnection>(key); if (connection == null) { continue; } if (string.IsNullOrEmpty(connection.ContainerId)) { continue; } if (!containers.ContainsKey(connection.ContainerId)) { containers.Add(connection.ContainerId, IsContainerConnected(client, connection.ContainerId)); } if (containers[connection.ContainerId]) { continue; } if (client.Remove(key)) { updated = true; } } } return(updated); }
public bool Check() { bool updated = false; Dictionary <string, bool> containers = new Dictionary <string, bool>(); IDatabase database = _connection.GetDatabase(); foreach (string key in GetKeysByPattern(this.CreateDomainKey(string.Empty) + "*")) { DrapoConnection connection = Get <DrapoConnection>(database, key); if (connection == null) { continue; } if (string.IsNullOrEmpty(connection.ContainerId)) { continue; } if (!containers.ContainsKey(connection.ContainerId)) { containers.Add(connection.ContainerId, IsContainerConnected(database, connection.ContainerId)); } if (containers[connection.ContainerId]) { continue; } if (database.KeyDelete(key)) { updated = true; } } return(updated); }
public void Create(string domain, string connectionId, string containerId) { IDatabase database = _connection.GetDatabase(); DrapoConnection connection = new DrapoConnection(connectionId, domain, containerId); database.StringSet(this.CreateConnectionKey(domain, connectionId), Serialize(connection)); }
public void Create(string domain, string connectionId) { using (IRedisClient client = _redisManagerPool.GetClient()) { DrapoConnection connection = new DrapoConnection(connectionId, domain); client.Set <DrapoConnection>(this.CreateConnectionKey(domain, connectionId), connection); } }
public bool Identify(string domain, string connectionId, long identity) { DrapoConnection connection = this.Get(domain, connectionId); if (connection == null) { return(false); } connection.Identity = identity; return(true); }
public bool Identify(string domain, string connectionId, long identity) { IDatabase database = _connection.GetDatabase(); DrapoConnection connection = Get <DrapoConnection>(database, this.CreateConnectionKey(domain, connectionId)); if (connection == null) { return(false); } connection.Identity = identity; database.StringSet(this.CreateConnectionKey(domain, connectionId), Serialize(connection)); return(true); }
public bool Identify(string domain, string connectionId, long identity) { using (IRedisClient client = _redisManagerPool.GetClient()) { DrapoConnection connection = client.Get <DrapoConnection>(this.CreateConnectionKey(domain, connectionId)); if (connection == null) { return(false); } connection.Identity = identity; client.Set <DrapoConnection>(this.CreateConnectionKey(domain, connectionId), connection); } return(true); }
public List <DrapoConnection> GetAll(string domain) { List <DrapoConnection> connections = new List <DrapoConnection>(); IDatabase database = _connection.GetDatabase(); foreach (string key in GetKeysByPattern(this.CreateDomainKey(domain) + "*")) { DrapoConnection connection = Get <DrapoConnection>(database, key); if (connection != null) { connections.Add(connection); } } return(connections); }
public List <DrapoConnection> GetAll(string domain) { List <DrapoConnection> connections = new List <DrapoConnection>(); using (IRedisClient client = _redisManagerPool.GetClient()) { foreach (string key in client.GetKeysByPattern(this.CreateDomainKey(domain) + "*")) { DrapoConnection connection = client.Get <DrapoConnection>(key); if (connection != null) { connections.Add(connection); } } } return(connections); }