Ejemplo n.º 1
0
        private void fromBytes_v1(byte[] bytes)
        {
            try
            {
                using (MemoryStream m = new MemoryStream(bytes))
                {
                    using (BinaryReader reader = new BinaryReader(m))
                    {
                        version = (int)reader.ReadIxiVarUInt();

                        int id_len = (int)reader.ReadIxiVarUInt();
                        if (id_len > 0)
                        {
                            id = reader.ReadBytes(id_len);
                        }

                        int message_type = (int)reader.ReadIxiVarUInt();
                        type = (StreamMessageCode)message_type;

                        int encryption_type = (int)reader.ReadIxiVarUInt();
                        encryptionType = (StreamMessageEncryptionCode)encryption_type;

                        int sender_length = (int)reader.ReadIxiVarUInt();
                        if (sender_length > 0)
                        {
                            sender = reader.ReadBytes(sender_length);
                        }

                        int recipient_length = (int)reader.ReadIxiVarUInt();
                        if (recipient_length > 0)
                        {
                            recipient = reader.ReadBytes(recipient_length);
                        }

                        int data_length = (int)reader.ReadIxiVarUInt();
                        if (data_length > 0)
                        {
                            data = reader.ReadBytes(data_length);
                        }

                        encrypted = reader.ReadBoolean();

                        int sig_length = (int)reader.ReadIxiVarUInt();
                        if (sig_length > 0)
                        {
                            signature = reader.ReadBytes(sig_length);
                        }

                        timestamp = (long)reader.ReadIxiVarUInt();
                    }
                }
            }
            catch (Exception e)
            {
                Logging.error("Exception occured while trying to construct StreamMessage from bytes: " + e);
            }
        }
Ejemplo n.º 2
0
        public StreamMessage(byte[] bytes)
        {
            try
            {
                using (MemoryStream m = new MemoryStream(bytes))
                {
                    using (BinaryReader reader = new BinaryReader(m))
                    {
                        int id_len = reader.ReadInt32();
                        id = reader.ReadBytes(id_len);

                        int message_type = reader.ReadInt32();
                        type = (StreamMessageCode)message_type;

                        int encryption_type = reader.ReadInt32();
                        encryptionType = (StreamMessageEncryptionCode)encryption_type;

                        int sender_length = reader.ReadInt32();
                        if (sender_length > 0)
                        {
                            sender = reader.ReadBytes(sender_length);
                        }

                        int recipient_length = reader.ReadInt32();
                        if (recipient_length > 0)
                        {
                            recipient = reader.ReadBytes(recipient_length);
                        }

                        int data_length = reader.ReadInt32();
                        if (data_length > 0)
                        {
                            data = reader.ReadBytes(data_length);
                        }

                        int tx_length = reader.ReadInt32();
                        if (tx_length > 0)
                        {
                            transaction = reader.ReadBytes(tx_length);
                        }

                        int sig_length = reader.ReadInt32();
                        if (sig_length > 0)
                        {
                            sigdata = reader.ReadBytes(sig_length);
                        }

                        encrypted    = reader.ReadBoolean();
                        sigEncrypted = reader.ReadBoolean();
                    }
                }
            }
            catch (Exception e)
            {
                Logging.error("Exception occured while trying to construct StreamMessage from bytes: " + e);
            }
        }
Ejemplo n.º 3
0
 public StreamMessage()
 {
     id             = Guid.NewGuid().ToByteArray(); // Generate a new unique id
     type           = StreamMessageCode.info;
     sender         = null;
     recipient      = null;
     data           = null;
     encryptionType = StreamMessageEncryptionCode.spixi1;
     timestamp      = Clock.getNetworkTimestamp();
 }
Ejemplo n.º 4
0
        private string id;                // Message unique id

        public StreamMessage()
        {
            id             = Guid.NewGuid().ToString(); // Generate a new unique id
            type           = StreamMessageCode.info;
            sender         = null;
            recipient      = null;
            transaction    = null;
            data           = null;
            sigdata        = null;
            encryptionType = StreamMessageEncryptionCode.spixi1;
        }