Esempio n. 1
0
        protected virtual bool BeginReadData()
        {
            bool       flag       = false;
            IPCContent ipcContent = new IPCContent()
            {
                data        = new byte[this.BufferSize],
                CancelToken = this._cancelTokenSrc.Token
            };

            WeGameHelper.WriteDebugString(nameof(BeginReadData));
            try
            {
                if (this._pipeStream != null)
                {
                    this._pipeStream.BeginRead(ipcContent.data, 0, this.BufferSize, new AsyncCallback(this.ReadCallback), (object)ipcContent);
                    flag = true;
                }
            }
            catch (IOException ex)
            {
                this._pipeBrokenFlag = true;
                WeGameHelper.WriteDebugString("BeginReadData Exception, {0}", (object)ex.Message);
            }
            return(flag);
        }
Esempio n. 2
0
        protected virtual bool BeginReadData()
        {
            bool       result     = false;
            IPCContent iPCContent = new IPCContent
            {
                data        = new byte[BufferSize],
                CancelToken = _cancelTokenSrc.Token
            };

            WeGameHelper.WriteDebugString("BeginReadData");
            try
            {
                if (_pipeStream == null)
                {
                    return(result);
                }
                _pipeStream.BeginRead(iPCContent.data, 0, BufferSize, ReadCallback, iPCContent);
                result = true;
                return(result);
            }
            catch (IOException ex)
            {
                _pipeBrokenFlag = true;
                WeGameHelper.WriteDebugString("BeginReadData Exception, {0}", ex.Message);
                return(result);
            }
        }
Esempio n. 3
0
        public override void ReadCallback(IAsyncResult result)
        {
            IPCContent obj = (IPCContent)result.AsyncState;

            base.ReadCallback(result);
            if (!obj.CancelToken.IsCancellationRequested)
            {
                ContinueReadOrWait();
            }
            else
            {
                WeGameHelper.WriteDebugString("servcer.ReadCallback cancel");
            }
        }
Esempio n. 4
0
        public override void ReadCallback(IAsyncResult result)
        {
            IPCContent obj = (IPCContent)result.AsyncState;

            base.ReadCallback(result);
            if (!obj.CancelToken.IsCancellationRequested)
            {
                if (GetPipeStream().IsConnected)
                {
                    BeginReadData();
                }
            }
            else
            {
                WeGameHelper.WriteDebugString("ReadCallback cancel");
            }
        }
Esempio n. 5
0
        public virtual void ReadCallback(IAsyncResult result)
        {
            WeGameHelper.WriteDebugString("ReadCallback: " + Thread.CurrentThread.ManagedThreadId.ToString());
            IPCContent asyncState = (IPCContent)result.AsyncState;

            try
            {
                int count = this._pipeStream.EndRead(result);
                if (!asyncState.CancelToken.IsCancellationRequested)
                {
                    if (count <= 0)
                    {
                        return;
                    }
                    this._totalData.AddRange(((IEnumerable <byte>)asyncState.data).Take <byte>(count));
                    if (!this._pipeStream.IsMessageComplete)
                    {
                        return;
                    }
                    this.AddPackToList(this._totalData);
                    this._totalData = new List <byte>();
                }
                else
                {
                    WeGameHelper.WriteDebugString("IPCBase.ReadCallback.cancel");
                }
            }
            catch (IOException ex)
            {
                this._pipeBrokenFlag = true;
                WeGameHelper.WriteDebugString("ReadCallback Exception, {0}", (object)ex.Message);
            }
            catch (InvalidOperationException ex)
            {
                this._pipeBrokenFlag = true;
                WeGameHelper.WriteDebugString("ReadCallback Exception, {0}", (object)ex.Message);
            }
        }
Esempio n. 6
0
        public virtual void ReadCallback(IAsyncResult result)
        {
            WeGameHelper.WriteDebugString("ReadCallback: " + Thread.CurrentThread.ManagedThreadId.ToString());
            IPCContent iPCContent = (IPCContent)result.AsyncState;

            try
            {
                int num = _pipeStream.EndRead(result);
                if (!iPCContent.CancelToken.IsCancellationRequested)
                {
                    if (num > 0)
                    {
                        _totalData.AddRange(iPCContent.data.Take(num));
                        if (_pipeStream.IsMessageComplete)
                        {
                            AddPackToList(_totalData);
                            _totalData = new List <byte>();
                        }
                    }
                }
                else
                {
                    WeGameHelper.WriteDebugString("IPCBase.ReadCallback.cancel");
                }
            }
            catch (IOException ex)
            {
                _pipeBrokenFlag = true;
                WeGameHelper.WriteDebugString("ReadCallback Exception, {0}", ex.Message);
            }
            catch (InvalidOperationException ex2)
            {
                _pipeBrokenFlag = true;
                WeGameHelper.WriteDebugString("ReadCallback Exception, {0}", ex2.Message);
            }
        }