Inheritance: Message
 private void RunProcessor(API.Request request, Processor processor, string processorName)
 {
     API.Response response = null;
     try
     {
         // Threadpooling
         response = processor.process(request);
     }
     catch (Exception e)
     {
         Logger.Error("Failed to process message with processor " + processor.GetType() + " : " + e.Message, e);
         try
         {
             Type responseType = Type.GetType("Gwupe.Cloud.Messaging.Response." + processorName + "Rs");
             response              = (API.Response)responseType.GetConstructor(Type.EmptyTypes).Invoke(new object[] {});
             response.error        = "UNKNOWN_ERROR";
             response.errorMessage = e.Message;
         }
         catch (Exception exception)
         {
             Logger.Error("Failed to determine return type for " + processorName);
             response = new ErrorRs
             {
                 errorMessage = "Failed to determine return type for " + processorName,
                 error        = "INTERNAL_SERVER_ERROR"
             };
         }
     }
     finally
     {
         SendResponse(response, request);
     }
 }
 private void SendResponse(API.Response response, API.Request request)
 {
     response.id = request.id;
     //response.date = DateTime.Now;
     try
     {
         _messageHander.SendMessage(response);
     }
     catch (Exception e)
     {
         Logger.Info("Failed to send response for request " + request.id + " : " + e.Message);
     }
 }
Esempio n. 3
0
 public void ProcessResponse(API.Response response)
 {
     try
     {
         _responseStore.Add(response.id, response);
         try
         {
             // Signal the wait handler
             _responseWaiters[response.id].Set();
         }
         catch (KeyNotFoundException e)
         {
             Logger.Error("No event handler found to message [" + response.id + "] : " + e.Message);
         }
     }
     catch (Exception e)
     {
         Logger.Error("Failed to process response " + response, e);
     }
 }
Esempio n. 4
0
 public TRs SendRequest <TRq, TRs>(TRq request) where TRq : API.Request where TRs : API.Response
 {
     //request.date = DateTime.Now;
     try
     {
         _messageHandler.SendMessage(request);
     }
     catch (Exception e)
     {
         throw new IOException("Failed to send request to server : " + e.Message, e);
     }
     API.Response response = AwaitResponse(request);
     if (response is ErrorRs)
     {
         Logger.Error("Error sending message [" + request.id + " - " + request.type + "] : [" + response.error + "] " + response.errorMessage);
         throw new RemoteException(response.errorMessage, response.error);
     }
     if (!response.isValid())
     {
         Logger.Error("Messaging error sending message [" + request.id + " - " + request.type + "] : [" + response.error + "] " + response.errorMessage);
         throw new MessageException <TRs>((TRs)response);
     }
     return((TRs)response);
 }
Esempio n. 5
0
 private void ProcessRateResponse(RateRq request, Response response, Exception e)
 {
     if (e != null)
     {
         Logger.Error("Failed to send the rating request : " + e.Message, e);
     }
     else
     {
         Logger.Debug("Successfully rated " + SecondParty.Party.Username + " " + request.rating + " for " +
                      request.ratingName + " for interaction " + request.interactionId);
     }
 }