private void TransportKeepAlive() { if (_client.IsSocketConnected == false) { try { _client.Close(); } catch { } } if (_client.TransportState == TcpTransportState.Closed) { var oldClient = _client; if (oldClient == null) { throw new RpcException("FastRpcClient TransportKeepAlive failed,client has been been closed"); } var newClient = (SimpleRpcClient)SimpleRpcClientPoolRoot.Depool(ServerIP, ServerPort); var originalClient = Interlocked.CompareExchange(ref _client, newClient, oldClient); if (originalClient != oldClient) { SimpleRpcClientPoolRoot.Enpool(newClient); throw new RpcException("FastRpcClient TransportKeepAlive failed,client has been been closed"); } } }
public FastRpcClient(IPAddress ip, int port) { ServerIP = ip; ServerPort = port; _client = (SimpleRpcClient)SimpleRpcClientPoolRoot.Depool(ip, port); }