Ejemplo n.º 1
0
 public static void Main(string[] commandLineArguments)
 {
     MsmLogging.configureLogging();
     log.Debug("MSM starting#args@" + commandLineArguments.Length);
     if (commandLineArguments.Length != 1)
     {
         log.Warn("Invalid command line specified : @JSON#" + commandLineArguments);
         sendInvalidCommandLineJsonResponse(commandLineArguments);
     }
     else
     {
         try {
             var json    = commandLineArguments[REQUEST_BODY_OFFSET];
             var request = new MsmMonitorRequest(json);
             log.Debug("Request forged@" + request.ToString());
             var monitor = new MintySenorMonitor(request);
             log.Debug("Monitor forged@" + monitor.ToString());
             sendValidJsonResponse(monitor.getSensorInfoAsJSON());
         } catch (MsmException e) {
             log.Error("@" + e.InnerException.Source + "#" + e.Message, e);
             sendInvalidJsonResponse(e);
         }
     }
 }
Ejemplo n.º 2
0
 public static String processRequest(String json)
 {
     log.Info("MsmJniWrapper poll...");
     if (json == null)
     {
         log.Debug("Invalid JSON request specified : @JSON#" + json);
         var e = new MsmException("Invalid JSON Request Argument");
         e.hint.message = "You must provide a valid MSMRequest in a JSON format";
         e.hint.input   = Newtonsoft.Json.JsonConvert.SerializeObject(json);
         e.hint.output  = "Usage: new MsmJniWrapper().poll({json:here})";
         e.hint.result  = "Example Usage: MsmJniWrapper().poll({debug:true})";
         return(Newtonsoft.Json.JsonConvert.SerializeObject(e));
     }
     else
     {
         try {
             var monitor = new MintySenorMonitor(new MsmMonitorRequest(json));
             return(monitor.getSensorInfoAsJSON());
         } catch (MsmException e) {
             log.Debug("@" + e.InnerException.Source + "#" + e.Message, e);
             return(Newtonsoft.Json.JsonConvert.SerializeObject(e));
         }
     }
 }