예제 #1
0
        private void Run()
        {
            EriverProtocol prot = new EriverProtocol();

            // Sending name first according to spec.
            prot.Kind       = Command.Name;
            prot.Name       = new Name();
            prot.Name.Value = name;
            Send(prot);

            while (!shutdown.WaitOne(0) && !stop.WaitOne(0))
            {
                try
                {
                    prot = readerWriter.Read();
                    using (log4net.ThreadContext.Stacks["NDC"].Push("ConnHandler_Handlers"))
                    {
                        var m = ConnHandler_Handlers.Messages[CommandConvert.ToByte(prot.Kind)]();
                        logger.Debug("Read packet: " + prot);
                        m.Accept(this, prot);
                    }
                }
                catch (InvalidOperationException e)
                {
                    using (log4net.ThreadContext.Stacks["NDC"].Push("InvalidOperationException"))
                    {
                        stop.Set();
                        logger.Error("Error in stream.");
                        logger.Debug(e);
                    }
                }
            }
        }
예제 #2
0
        public void ReadWriteTest()
        {
            foreach (Command cmd in Enum.GetValues(typeof(Command)))
            {
                SetUp();
                EriverProtocol ep = CreateTestProtocol(cmd);
                esrw.Write(ep);
                EriverProtocol new_ep = esrw.Read();

                Assert.AreEqual(ep, new_ep);
                Assert.AreEqual <EriverProtocol>(ep, new_ep);
            }
        }
예제 #3
0
 private void handle()
 {
     while (true)
     {
         if (esrw != null)
         {
             EriverProtocol ep = esrw.Read();
             if (ep.Kind == Command.GetPoint)
             {
                 MovePointer(ep.GetPoint.X, ep.GetPoint.Y);
             }
         }
     }
 }