예제 #1
0
 protected override void Loop(CancellationToken token)
 {
     using (var tcpClient = new TcpClient(_config.Hostname, ControlPort))
     using (NetworkStream stream = tcpClient.GetStream())
     {
         var buffer = new byte[NetworkBufferSize];
         while (token.IsCancellationRequested == false)
         {
             int offset = 0;
             if (tcpClient.Available > 0)
             {
                 offset += stream.Read(buffer, offset, buffer.Length);
                 var packet = new ConfigurationPacket
                     {
                         Timestamp = DateTime.UtcNow.Ticks,
                         Data = buffer
                     };
                 _configurationAcquired(packet);
             }
             Thread.Sleep(10);
         }
     }
 }
예제 #2
0
 private void OnConfigurationPacketAcquired(ConfigurationPacket packet)
 {
     string config = Encoding.ASCII.GetString(packet.Data);
     Trace.TraceInformation(config);
 }