Esempio n. 1
0
        public bool Update(long deltaTime)
        {
            // check if we're still alive.
            _msSinceData += deltaTime;

            // flush input data
            try
            {
                if (!IsConnected())
                {
                    DeadForMs += deltaTime;
                    return(false);
                }

                var avail = _socket.Available;

                if (avail <= 0)
                {
                    return(true); // no data received, all is good.
                }
                // flush the stuff we received into _inBufferStream
                var recv = _socket.Receive(_inBufferStream, 0, avail, SocketFlags.None);

                // flush the _inBufferStream into the circular InStream
                InStream.WriteBlock(_inBufferStream, 0, recv);
                _msSinceData = 0;

                return(true);
            }
            catch (Exception e)
            {
                HandleException(e);
            }

            return(false);
        }