private async Task ProcessClientConnect(Uri uri, HeloMessage helo) { Client client; // TODO : Move into IHostProtocol // Check if we're registering another protocol if (helo.ClientId.HasValue) { if (!_clientCollection.TryGet(helo.ClientId.Value, out client)) { // Something weird is going on // Ignore the message return; } // Register the protocol client.Uris.Add(uri.ProtocolType(), uri); // Update the client _clientCollection.Add(client); } else if (_clientCollection.TryGet(uri, out client)) { if (client.ClientId.Equals(helo.ClientId)) { // Ignore } else { // TODO: Renegotiate security } return; } else { // No matching client client = new Client(uri, helo); _clientCollection.Add(client); } // Acknowledge the request var ack = new HeloAckMessage(client); await _messageCenter.SendMessage(uri, ack); }
public Client(Uri uri, HeloMessage helo) { Uris.Add(uri.ProtocolType(), uri); }