示例#1
0
        public string Read()
        {
            var lengthString = string.Empty;

            while (true)
            {
                var lengthCharacter = _session.Read(1);
                if (lengthCharacter == ":")
                {
                    break;
                }
                lengthString += lengthCharacter;
                if (lengthString == "bye")
                {
                    return("bye");
                }
            }
            var messageByteLength = int.Parse(lengthString);
            var message           = _session.Read(messageByteLength);

            if (EndIdentifier.Matches(message))
            {
                CloseSession();
            }
            return(message);
        }
示例#2
0
        public string Read()
        {
            var lengthString = string.Empty;

            while (true)
            {
                var lengthCharacter = channel.Read(1);
                if (lengthCharacter == ":")
                {
                    break;
                }
                lengthString += lengthCharacter;
            }
            var messageByteLength = int.Parse(lengthString);
            var message           = channel.Read(messageByteLength);

            if (EndIdentifier.Matches(message))
            {
                IsEnd = true;
                channel.Close();
                return(null);
            }
            return(message);
        }