Пример #1
0
        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);
        }
Пример #2
0
        private WsConnection FindConnection(string uniqueId)
        {
            WsConnection result = null;

            foreach (var connection in _connectionList)
            {
                if (connection.UniqueId == uniqueId)
                {
                    result = connection;
                    break;
                }
            }

            return(result);
        }