Пример #1
0
 public void PollForMessages()
 {
     try
     {
         using (var gaugeConnection = new GaugeConnection(new TcpClientWrapper(Utils.GaugePort)))
         {
             while (gaugeConnection.Connected)
             {
                 var message   = Message.Parser.ParseFrom(gaugeConnection.ReadBytes().ToArray());
                 var processor = _messageProcessorFactory.GetProcessor(message.MessageType,
                                                                       message.MessageType == Message.Types.MessageType.SuiteDataStoreInit);
                 var response = processor.Process(message);
                 gaugeConnection.WriteMessage(response);
                 if (message.MessageType == Message.Types.MessageType.KillProcessRequest)
                 {
                     return;
                 }
             }
         }
     }
     catch (Exception ex)
     {
         Logger.Error(ex);
     }
 }
 public override Task <Empty> CacheFile(CacheFileRequest request, ServerCallContext context)
 {
     _factory.GetProcessor(Message.Types.MessageType.CacheFileRequest)
     .Process(new Message {
         CacheFileRequest = request
     });
     return(Task.FromResult(new Empty()));
 }