コード例 #1
0
        public override void AddBytes(byte[] bytes, int length)
        {
            pipeStreamReader.Write(bytes, 0, length);

            while ((message = Serializer.DeserializeWithLengthPrefix <T>(pipeStreamReader, PrefixStyle.Base128)) != null)
            {
                FireEvent(message);
            }
        }
コード例 #2
0
        public override void AddBytes(byte[] bytes, int length)
        {
            pipeStreamReader.Write(bytes, 0, length);

            // Will raise exception if there is a problem with deserialization
            try
            {
                while ((message = Serializer.DeserializeWithLengthPrefix <T>(pipeStreamReader, _prefixStyle)) != null)
                {
                    FireEvent(message);
                }
            } catch (Exception e_parse)
            {
                logger.Warn(e_parse, "Incomplete Protobuf message");
            }
        }
コード例 #3
0
        public override void AddBytes(byte[] bytes, int length)
        {
            if (_prefixStyle == PrefixStyle.Fixed32)
            {
                for (int i = 0; i < length; i++)
                {
                    if (nBytesRcv < 4)
                    {
                        nDataLength |= (bytes[i] << (8 * nBytesRcv++));
                    }
                    else
                    {
                        pipeStreamReader.WriteByte(bytes[i]);
                        if (--nDataLength == 0)
                        {
                            message = Serializer.Deserialize <T>(pipeStreamReader);
                            FireEvent(message);
                            nBytesRcv = nDataLength = 0;
                        }
                    }
                }
            }
            else
            {
                pipeStreamReader.Write(bytes, 0, length);

                // Will log message if there is a problem with deserialization
                try
                {
                    while ((message = Serializer.DeserializeWithLengthPrefix <T>(pipeStreamReader, _prefixStyle)) != null)
                    {
                        FireEvent(message);
                    }
                }
                catch (Exception e_parse)
                {
                    logger?.LogWarning(e_parse, "Incomplete Protobuf message");
                }
            }
        }
コード例 #4
0
 public override void AddBytes(byte[] bytes, int length)
 {
     pipeStreamReader.Write(bytes, 0, length);
 }