public RClient(Uri uri, int timeOut = 3000) { if (string.IsNullOrEmpty(uri.Scheme) || string.Compare(uri.Scheme, "rpc", true) != 0) { ExceptionCollector.Add("Consumer.RClient.Init Error", new RPCSocketException("当前连接协议不正确,请使用格式rpc://ip:port")); return; } _timeOut = timeOut; _disorderSyncHelper = new DisorderSyncHelper(_timeOut); var ipPort = DNSHelper.GetIPPort(uri); _rUnpacker = new RUnpacker(); SocketOptionBuilder builder = SocketOptionBuilder.Instance; var option = builder.SetSocket() .UseIocp <RUnpacker>() .SetIP(ipPort.Item1) .SetPort(ipPort.Item2) .SetReadBufferSize(10240) .SetWriteBufferSize(10240) .SetTimeOut(_timeOut) .Build(); _client = SocketFactory.CreateClientSocket(option); _client.OnReceive += OnReceived; _client.OnDisconnected += _client_OnDisConnected; }
public RClient(Uri uri) { if (string.IsNullOrEmpty(uri.Scheme) || string.Compare(uri.Scheme, "rpc", true) != 0) { ExceptionCollector.Add("Consumer.RClient.Init Error", new RPCSocketException("当前连接协议不正确,请使用格式rpc://ip:port")); return; } var ipPort = DNSHelper.GetIPPort(uri); _RContext = new RContext(); SocketOptionBuilder builder = SocketOptionBuilder.Instance; var option = builder.SetSocket() .UseIocp(_RContext) .SetIP(ipPort.Item1) .SetPort(ipPort.Item2) .SetReadBufferSize() .SetWriteBufferSize() .Build(); _client = SocketFactory.CreateClientSocket(option); _client.OnReceive += OnReceived; _client.OnDisconnected += _client_OnDisConnected; }