private TcpTalk GetTalker(string connectionId, TcpAddress destination) { lock (_talkers) { TcpTalk talker; if (!_talkers.TryGetValue(connectionId, out talker)) { talker = new TcpTalk(_port, destination); talker.HandleMessage(HandleMessage); _talkers[connectionId] = talker; } return talker; } }
private void NewClientConnection(TcpClient client) { lock (_talkers) { var talker = new TcpTalk(client); talker.HandleMessage(HandleMessage); } }