コード例 #1
0
        public ConnectionMessage(byte[] encoding)
            : this()
        {
            try
            {
                MemoryStream input        = new MemoryStream(encoding, 0, encoding.Length, false);
                BinaryReader binaryReader = new BinaryReader(new BufferedStream(input));

                MessagesEncodingUtil.ReadByte(binaryReader);
            }
            catch (Exception)
            {
                throw new BinaryEncodingException("Encode");
            }
        }
コード例 #2
0
        public ByteArrayMessage(byte[] encoding)
            : this()
        {
            try
            {
                MemoryStream input        = new MemoryStream(encoding, 0, encoding.Length, false);
                BinaryReader binaryReader = new BinaryReader(new BufferedStream(input));

                MessagesEncodingUtil.ReadByte(binaryReader);
                int binaryArrayLength = MessagesEncodingUtil.ReadInt(binaryReader);
                ByteArray = MessagesEncodingUtil.ReadByteArray(binaryReader, binaryArrayLength);
            }
            catch (Exception)
            {
                throw new BinaryEncodingException("Encode");
            }
        }
コード例 #3
0
        public PeerAddressMessage(byte[] encoding)
            : this()
        {
            try
            {
                MemoryStream memoryStream = new MemoryStream(encoding, 0, encoding.Length, false);
                BinaryReader binaryReader = new BinaryReader(new BufferedStream(memoryStream));

                TypeOfMessage = (MessageType)MessagesEncodingUtil.ReadByte(binaryReader);

                IPEndPoint localEndPoint  = ParseIpEndPoint(MessagesEncodingUtil.ReadString(binaryReader));
                IPEndPoint publicEndPoint = ParseIpEndPoint(MessagesEncodingUtil.ReadString(binaryReader));

                PeerAddress = new PeerAddress(localEndPoint, publicEndPoint);
            }
            catch (Exception)
            {
                throw new BinaryEncodingException("Encode");
            }
        }