Beispiel #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="urls"></param>
        /// <param name="token">Throws a <see cref="T:System.OperationCanceledException" /> if this token has had cancellation requested.</param>
        /// <returns></returns>
        /// <exception cref="T:System.OperationCanceledException">The token has had cancellation requested.</exception>
        public string TryConnectTo(List <string> urls, CancellationToken token)
        {
            if (_urls != urls)
            {
                _urls = urls;
            }

            _webSocketManager?.Dispose();

            foreach (var url in urls)
            {
                _webSocketManager = new WebSocketManager(url, _jsonSerializerSettings);
                var resp = GetConfig(token);
                if (!resp.IsError)
                {
                    dynamic conf   = resp.Result;
                    var     scid   = conf.STEEMIT_CHAIN_ID as JValue;
                    var     smpsbd = conf.STEEMIT_MIN_PAYOUT_SBD as JValue;
                    if (scid != null && smpsbd != null)
                    {
                        var cur = smpsbd.Value <string>();
                        var str = scid.Value <string>();
                        if (!string.IsNullOrEmpty(cur) && !string.IsNullOrEmpty(str))
                        {
                            _sbdSymbol = new Money(cur).Currency;
                            _chainId   = Hex.HexToBytes(str);
                            return(url);
                        }
                    }
                }
                _webSocketManager.Dispose();
            }

            return(string.Empty);
        }
Beispiel #2
0
 public OperationManager(string url, byte[] chainId, JsonSerializerSettings jsonSerializerSettings)
 {
     _webSocketManager = new WebSocketManager(url, jsonSerializerSettings);
     _chainId          = chainId;
 }