/// <summary> /// /// </summary> /// <param name="stream"></param> /// <param name="notify">A callback that occurs after an asynchronous read returns successfully. This is not signaled all the time, only when calls to <see cref="TryRead"/> fail</param> /// <param name="onException">Is called anytime that the socket raises an exception. The class is automatically disposed.</param> public StreamReading(Stream stream, Action notify, Action <Exception> onException) { m_notify = notify ?? throw new ArgumentNullException(nameof(notify)); m_stream = stream ?? throw new ArgumentNullException(nameof(stream)); m_onException = onException ?? throw new ArgumentNullException(nameof(onException)); m_readBuffer = new byte[3000]; m_readDecoder = new CtpReadDecoder(); m_continueRead = new WeakActionAsync <Task <int> >(ContinueRead); }
/// <summary> /// /// </summary> /// <param name="stream"></param> /// <param name="notify">A callback that occurs after an asynchronous read returns successfully. This is not signaled all the time, only when calls to <see cref="TryWrite"/> fail</param> /// <param name="onException">Is called anytime that the socket raises an exception. The class is automatically disposed.</param> public StreamWriting(Stream stream, Action notify, Action <Exception> onException) { m_sendTimeout = 5000; m_notify = notify ?? throw new ArgumentNullException(nameof(notify)); m_stream = stream ?? throw new ArgumentNullException(nameof(stream)); m_onException = onException ?? throw new ArgumentNullException(nameof(onException)); m_processWriteTimeouts = new ScheduledTask(); m_processWriteTimeouts.Running += ProcessWriteTimeoutsRunning; m_writeEncoder = new CtpWriteEncoder(CtpCompressionMode.None, WriteCallback); m_writeQueue = new Queue <Tuple <ShortTime, PooledBuffer, ManualResetEventSlim> >(); m_continueWrite = new WeakActionAsync <Task>(ContinueWrite); }