public void RemoveReceiver(Guid receiverId)
        {
            HubConnectedClient client = _clients.Single(receiverId);

            if (client != null)
            {
                Groups.Remove(client.ConnectionId, ReceiverGroup);
                _clients.Remove(client.Id);
            }

            OnConnectedClientRemoved(client);
        }
        public void Send(Guid senderId, Message message)
        {
            HubConnectedClient client         = _clients.Single(senderId);
            string             excludedClient = string.Empty;

            if (client != null)
            {
                excludedClient = client.ConnectionId;
            }

            var group = Clients.Group(ReceiverGroup, excludedClient);

            if (group != null)
            {
                group.Receive(senderId, message);
            }
        }
        public void AddReceiver(ConnectedClientData clientData)
        {
            HubConnectedClient client = new HubConnectedClient();

            client.ConnectionId = Context.ConnectionId;
            client.Id           = clientData.Id;
            client.PublicKey    = clientData.PublicKey;

            HubConnectedClient existing = _clients.Single(client.Id);

            if (existing != null)
            {
                Groups.Remove(existing.ConnectionId, ReceiverGroup);
                _clients.Remove(client.Id);
            }

            _clients.Add(client);
            Groups.Add(client.ConnectionId, ReceiverGroup);

            OnConnectedClientAdded(client);
        }
 protected virtual void OnConnectedClientRemoved(HubConnectedClient client)
 {
 }
 protected virtual void OnConnectedClientAdded(HubConnectedClient client)
 {
 }