Beispiel #1
0
        internal ShortConnectionRpcClient(IPAddress ip, int port)
        {
            ServerIP   = ip;
            ServerPort = port;

            _client = AutoReconnectRpcClientFactory.Create(ip, port);
        }
Beispiel #2
0
        public void Close()
        {
            if (_client == null)
            {
                return;
            }

            var oldValue = Interlocked.Exchange(ref _client, null);

            if (oldValue == null)
            {
                return;
            }

            AutoReconnectRpcClientFactory.TakeBack(oldValue);
        }
Beispiel #3
0
        private static AutoReconnectRpcClientFactory GetOrAddFactory(IPAddress ip, int port)
        {
            string key = ip + "_" + port;

            AutoReconnectRpcClientFactory factory = null;

            _factoryDictionary.TryGetValue(key, out factory);
            if (factory != null)
            {
                return(factory);
            }

            _factoryDictionary.TryAdd(key, new AutoReconnectRpcClientFactory(ip, port));

            _factoryDictionary.TryGetValue(key, out factory);
            if (factory != null)
            {
                return(factory);
            }

            throw new Exception();
        }