public async Task <bool> Connect(string uniqueId, string channelName) { bool result = false; var connection = FindConnection(uniqueId); if (connection == null) { connection = new WsConnection(uniqueId, channelName); if (await connection.Connect(WsHostUrlConverter.ToWsUrl(HostUrl))) { _connectionList.Add(connection); result = true; } } else if (!connection.IsConnected) { if (await connection.Connect(WsHostUrlConverter.ToWsUrl(HostUrl))) { result = true; } } return(result); }
private WsConnection FindConnection(string uniqueId) { WsConnection result = null; foreach (var connection in _connectionList) { if (connection.UniqueId == uniqueId) { result = connection; break; } } return(result); }