public SocketRemotingClient(EndPoint serverEndPoint, SocketSetting setting = null, EndPoint localEndPoint = null) { serverEndPoint.CheckNotNull("serverEndPoint"); _serverEndPoint = serverEndPoint; _localEndPoint = localEndPoint; _setting = setting ?? new SocketSetting(); _receiveDataBufferPool = new BufferPool(_setting.ReceiveDataBufferSize, _setting.ReceiveDataBufferPoolSize); _clientSocket = new ClientSocket(_serverEndPoint, _localEndPoint, _setting, _receiveDataBufferPool, HandleReplyMessage); _responseFutureDict = new ConcurrentDictionary <long, ResponseFuture>(); _replyMessageQueue = new BlockingCollection <byte[]>(new ConcurrentQueue <byte[]>()); _responseHandlerDict = new Dictionary <int, IResponseHandler>(); _connectionEventListeners = new List <IConnectionEventListener>(); _scheduleService = IocManager.Instance.Resolve <IScheduleService>(); _logger = IocManager.Instance.Resolve <ILoggerFactory>().Create(GetType().FullName); RegisterConnectionEventListener(new ConnectionEventListener(this)); }
public ClientSocket(EndPoint serverEndPoint, EndPoint localEndPoint, SocketSetting setting, IBufferPool receiveDataBufferPool, Action <ITcpConnection, byte[]> messageArrivedHandler) { serverEndPoint.CheckNotNull("serverEndPoint"); setting.CheckNotNull("setting"); receiveDataBufferPool.CheckNotNull("receiveDataBufferPool"); messageArrivedHandler.CheckNotNull("messageArrivedHandler"); _connectionEventListeners = new List <IConnectionEventListener>(); _serverEndPoint = serverEndPoint; _localEndPoint = localEndPoint; _setting = setting; _receiveDataBufferPool = receiveDataBufferPool; _messageArrivedHandler = messageArrivedHandler; _waitConnectHandle = new ManualResetEvent(false); _socket = SocketUtils.CreateSocket(_setting.SendBufferSize, _setting.ReceiveBufferSize); _logger = IocManager.Instance.Resolve <ILoggerFactory>().Create(GetType().FullName); _flowControlThreshold = _setting.SendMessageFlowControlThreshold; }
public static string ToAddress(this EndPoint endpoint) { endpoint.CheckNotNull("endpoint"); return(((IPEndPoint)endpoint).ToAddress()); }