Ejemplo n.º 1
0
        /// <summary>
        /// Write to the data adapter
        /// </summary>
        /// <param name="frame">The frame to write</param>
        public void Write(DataFrame frame)
        {
            if (!fixedConnection)
            {
                string       s      = BinaryEncoding.Instance.GetString(frame.ToArray());
                StringReader reader = new StringReader(s);
                string       header = reader.ReadLine();

                while (header != null)
                {
                    if (header.StartsWith("Connection:"))
                    {
                        s = s.Replace(header, "Connection: close");
                        fixedConnection = true;
                        break;
                    }
                    else if (header.Length == 0)
                    {
                        fixedConnection = true;
                        break;
                    }

                    header = reader.ReadLine();
                }

                frame.ConvertToBasic(s);
            }
            _adapter.Write(frame);
        }
Ejemplo n.º 2
0
        private void SendPacketLog(IDataAdapter adapter, PacketLogDocument doc, Logger logger)
        {
            LogPacket[] packets = doc.GetPackets();

            foreach (LogPacket p in packets)
            {
                DataFrame newFrame = p.Frame.CloneFrame();

                if (Config.ConvertToBasic)
                {
                    newFrame.ConvertToBasic();
                }

                adapter.Write(newFrame);
            }
        }
Ejemplo n.º 3
0
        public override void Run(IDataAdapter adapter, Utils.Logger logger)
        {
            DataFrame frame = adapter.Read();

            while (frame != null)
            {
                if (Config.ConvertToBasic)
                {
                    frame.ConvertToBasic();
                }

                adapter.Write(frame);

                frame = adapter.Read();
            }
        }
Ejemplo n.º 4
0
        public override void Run(DataAdapters.IDataAdapter adapter, Logger logger)
        {
            LogPacket[] packets = Config.GetPackets();
            DataFrameFilterExpression filters = Config.CreateFilters();
            int  pos         = 0;
            int  repeat      = 0;
            bool finished    = false;
            bool sendatstart = Config.SendAtStart;

            do
            {
                bool matchedFrame = false;

                if (sendatstart)
                {
                    matchedFrame = true;
                    sendatstart  = false;
                }
                else
                {
                    DataFrame frame = adapter.Read();

                    if ((frame == null) || (finished && Config.CloseAfterSend))
                    {
                        break;
                    }

                    matchedFrame = filters.IsMatch(frame);
                }

                if (matchedFrame)
                {
                    if (!finished)
                    {
                        // Send if any packets left
                        if (pos < packets.Length)
                        {
                            DataFrame current = packets[pos++].Frame.CloneFrame();
                            if (Config.ConvertToBasic)
                            {
                                current.ConvertToBasic();
                            }

                            adapter.Write(current);
                        }

                        if (pos == packets.Length)
                        {
                            repeat++;
                            pos = 0;
                        }

                        if (repeat >= Config.RepeatCount)
                        {
                            finished = true;

                            if (!Config.WaitForResponseOnClose && Config.CloseAfterSend)
                            {
                                break;
                            }
                        }
                    }
                }
            }while (true);
        }
Ejemplo n.º 5
0
 private void toolStripButtonConvertToBytes_Click(object sender, EventArgs e)
 {
     _currFrame.ConvertToBasic();
     UpdateFrame();
     UpdateFrameModified();
 }
Ejemplo n.º 6
0
        /// <summary>
        /// Write to the data adapter
        /// </summary>
        /// <param name="frame">The frame to write</param>
        public void Write(DataFrame frame)
        {
            if (!fixedConnection)
            {
                string s = BinaryEncoding.Instance.GetString(frame.ToArray());
                StringReader reader = new StringReader(s);
                string header = reader.ReadLine();

                while(header != null)
                {
                    if (header.StartsWith("Connection:"))
                    {
                        s = s.Replace(header, "Connection: close");
                        fixedConnection = true;
                        break;
                    }
                    else if (header.Length == 0)
                    {
                        fixedConnection = true;
                        break;
                    }

                    header = reader.ReadLine();
                }

                frame.ConvertToBasic(s);
            }
            _adapter.Write(frame);
        }