Ejemplo n.º 1
0
        private void checker_CheckCompleted(object sender, CheckCompletedEventArgs e)
        {
            CmdServerReply reply = new CmdServerReply();
            reply.id = e.CmdId;
            reply.status = e.CheckResult.ToString();
            reply.info = e.SystemInfo;            
            reply.code = e.FailCode;
            reply.fail = e.FailInfo;
            reply.port = this.checkerPort;

            //if (captureBuf != null)
            //{
            //    reply.fail_picture = new byte[captureBuf.Length];
            //    captureBuf.CopyTo(reply.fail_picture, 0);
            //    captureBuf = null;
            //}

            cmdReader.SendToServer(reply);

            PeekNewCmd();
        }
Ejemplo n.º 2
0
 private void WriteReply(NetworkStream stream, CmdServerReply reply)
 {
     JsonSerializer serializer = new JsonSerializer();
     using (BsonWriter writer = new BsonWriter(stream))
     {
         serializer.Serialize(writer, reply);
         writer.Flush();
         writer.Close();
     }
 }
Ejemplo n.º 3
0
 private void OnCmdReplyProcessed(CmdServerReply reply)
 {
     var handler = CmdReplyProcessed;
     if (handler != null)
     {
         handler(this, new CmdReplyProcessedEventArgs { Reply = reply });
     }
 }
Ejemplo n.º 4
0
        public void SendToServer(CmdServerReply reply)
        {
            if (reply == null)
            {
                throw new ArgumentNullException("reply");
            }

            try
            {
                Socket sock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                sock.Connect("127.0.0.1", ConfigHelper.InternalServerPort);

                using (NetworkStream stream = new NetworkStream(sock))
                {
                    WriteReply(stream, reply);
                    stream.Close();
                }
            }
            catch (Exception ex)
            {
                Logger.AddError("Failed to send reply", ex);
            }
        }
Ejemplo n.º 5
0
 private void SendCmdReply(CmdServerReply reply)
 {
     lock (replies)
     {
         replies.Add(reply);
     }
 }