Ejemplo n.º 1
0
 public bool Equals(FrameQueuesMessage queues)
 {
     if (Queues.Count != queues.Queues.Count)
     {
         return(false);
     }
     if (Head != queues.Head)
     {
         return(false);
     }
     for (int i = 0; i < Queues.Count; i++)
     {
         var framesKV  = Queues[i];
         var framesOKV = queues.Queues[i];
         if (framesKV.Key != framesOKV.Key)
         {
             return(false);
         }
         var frames  = framesKV.Value;
         var framesO = framesOKV.Value;
         for (int j = 0; j < frames.Length; i++)
         {
             if (!frames[j].Equals(framesO[j]))
             {
                 return(false);
             }
         }
     }
     return(true);
 }
Ejemplo n.º 2
0
        public void TestReadWrite()
        {
            MemoryStream ms      = new MemoryStream();
            var          oQueues = new FrameQueuesMessage();

            try {
                queues.Write(ms);
                ms.Position = 0;
                oQueues.Read(ms);
            } catch (System.Exception e) {
                Console.WriteLine("Exception");
                Console.WriteLine(e);
            }
            Assert.AreEqual(oQueues.ToString(), queues.ToString());
            Assert.Inconclusive("Test ReadWrite");
        }
Ejemplo n.º 3
0
        public void Init()
        {
            DateTime now = DateTime.Now;

            Console.WriteLine("Start Test FrameQueuesMessageTest!");
            queues = new FrameQueuesMessage("HelloQueue");
            queues.AppendQueue(0, new FrameMessage[] {
                new FrameMessage("Start", System.Text.Encoding.Default.GetBytes("Hello 1"), (ulong)now.Ticks),
                new FrameMessage("Hello", System.Text.Encoding.Default.GetBytes("Hello 2"), (ulong)now.Ticks + 10),
                new FrameMessage("Say", System.Text.Encoding.Default.GetBytes("Hello 3"), (ulong)now.Ticks + 20),
                new FrameMessage("Say", System.Text.Encoding.Default.GetBytes("Hello 4"), (ulong)now.Ticks),
                new FrameMessage("End", System.Text.Encoding.Default.GetBytes("Hello 5"), (ulong)now.Ticks)
            });
            queues.AppendQueue(1, new FrameMessage[] {
                new FrameMessage("Start", System.Text.Encoding.Default.GetBytes("Hello 11"), (ulong)now.Ticks),
                new FrameMessage("Hello", System.Text.Encoding.Default.GetBytes("Hello 21"), (ulong)now.Ticks + 10),
                new FrameMessage("Say", System.Text.Encoding.Default.GetBytes("Hello 31"), (ulong)now.Ticks + 20),
                new FrameMessage("Say", System.Text.Encoding.Default.GetBytes("Hello 41"), (ulong)now.Ticks),
                new FrameMessage("End", System.Text.Encoding.Default.GetBytes("Hello 51"), (ulong)now.Ticks)
            });
        }
Ejemplo n.º 4
0
        public void Recv(int time, Action <MessageType, Message, FrameMessage, FrameQueuesMessage> cb)
        {
            if (m_socket.Poll(time, SelectMode.SelectRead))
            {
                if (m_recvStream == null)
                {
                    m_recvStream = new NetworkStream(m_socket);
                }
                MessageType t = new MessageType(0);
                t.Read(m_recvStream);
                switch ((byte)t)
                {
                case MessageType.Normal:
                    Message msg = new Message();
                    msg.Read(m_recvStream);
                    cb(t, msg, null, null);
                    break;

                case MessageType.Frame:
                    FrameMessage frame = new FrameMessage();
                    frame.Read(m_recvStream);
                    cb(t, null, frame, null);
                    break;

                case MessageType.FrameQueues:
                    FrameQueuesMessage queues = new FrameQueuesMessage();
                    queues.Read(m_recvStream);
                    cb(t, null, null, queues);
                    break;

                default:
                    break;
                }
            }
            else
            {
                Thread.Sleep(time);
            }
        }
Ejemplo n.º 5
0
 public string SendQueues(FrameQueuesMessage msg)
 {
     return(send(MessageType.FrameQueues, msg));
 }