public FastRpcClient(IPAddress ip, int port) { ServerIP = ip; ServerPort = port; _client = (SimpleRpcClient)SimpleRpcClientFactory.Create(ip, port); }
public void Close() { if (_client == null) { return; } var oldValue = Interlocked.Exchange(ref _client, null); if (oldValue == null) { return; } SimpleRpcClientFactory.TakeBack(oldValue); }
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"); }