コード例 #1
0
        public FastRpcClient(IPAddress ip, int port)
        {
            ServerIP   = ip;
            ServerPort = port;

            _client = (SimpleRpcClient)SimpleRpcClientFactory.Create(ip, port);
        }
コード例 #2
0
        public void Close()
        {
            if (_client == null)
            {
                return;
            }

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

            if (oldValue == null)
            {
                return;
            }

            SimpleRpcClientFactory.TakeBack(oldValue);
        }
コード例 #3
0
        private static SimpleRpcClientFactory GetOrAddFactory(IPAddress ip, int port)
        {
            string key = ip + "_" + port;

            SimpleRpcClientFactory factory = null;

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

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

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

            throw new Exception("GetOrAddFactory error");
        }