Example #1
0
        public void Encapsulate(AbstractProtocol data)
        {
            AbstractProtocol outerProtocol = ((dynamic)protocolHandler).DownstreamProcess((dynamic)data);

            outerProtocol.innerObject = data;
            SenderDataReady?.Invoke(outerProtocol);
        }
Example #2
0
        public void Encapsulate(AbstractProtocol data)
        {
            using (MemoryStream stream = new MemoryStream(), dataStream = new MemoryStream())
            {
                try
                {
                    formatter.Serialize(dataStream, data);
                }
                catch
                {
                    throw new DeveloperError("DataSerializer", "Encapsulate",
                                             "Not serializable AbstractProtocol",
                                             "Please mark all protocol as [Serializable]");
                }

                dataStream.Seek(0, SeekOrigin.Begin);
                stream.Write(BitConverter.GetBytes(dataStream.Length), 0, 4);
                dataStream.CopyTo(stream);

                stream.Seek(0, SeekOrigin.Begin);
                SenderDataReady?.Invoke(stream);

                dataStream.Close();
                stream.Close();
            }
        }
Example #3
0
 public ProtocolTree()
 {
     root = new ProtocolTreeNode {
         protocolHandler = new DummyHandler <RootProtocol>()
     };
     root.SenderDataReady += obj => SenderDataReady?.Invoke(obj);
     AttachErrorHandler(root);
 }
Example #4
0
 public void PassThrough(AbstractProtocol data) => SenderDataReady?.Invoke(data);