Esempio n. 1
0
 public void ProcessRequest(MIGClientRequest request, MIGInterfaceCommand migCommand)
 {
     switch (migCommand.Command)
     {
     case "Events.Push":
         //TODO: implemet security and trust mechanism
         var stream      = new StreamReader(request.InputStream).ReadToEnd();
         var moduleEvent = JsonConvert.DeserializeObject <ModuleEvent>(
             stream,
             new JsonSerializerSettings()
         {
             Culture = System.Globalization.CultureInfo.InvariantCulture
         }
             );
         //
         // prefix remote event domain with HGIC:<remote_node_address>.<domain>
         moduleEvent.Module.Domain = "HGIC:" + request.RequestOrigin.Replace(".", "_") + "." + moduleEvent.Module.Domain;
         //
         var module = homegenie.Modules.Find(delegate(Module o)
         {
             return(o.Domain == moduleEvent.Module.Domain && o.Address == moduleEvent.Module.Address);
         });
         if (module == null)
         {
             module = moduleEvent.Module;
             homegenie.Modules.Add(module);
         }
         else
         {
             Utility.ModuleParameterSet(module, moduleEvent.Parameter.Name, moduleEvent.Parameter.Value);
         }
         // "<ip>:<port>" remote endpoint port is passed as the first argument from the remote point itself
         module.RoutingNode = request.RequestOrigin + (migCommand.GetOption(0) != "" ? ":" + migCommand.GetOption(0) : "");
         //
         homegenie.LogBroadcastEvent(
             moduleEvent.Module.Domain,
             moduleEvent.Module.Address,
             request.RequestOrigin,
             moduleEvent.Parameter.Name,
             moduleEvent.Parameter.Value
             );
         HomeGenie.Service.HomeGenieService.RoutedEvent eventData = new HomeGenie.Service.HomeGenieService.RoutedEvent()
         {
             Sender    = request.RequestOrigin,
             Module    = module,
             Parameter = moduleEvent.Parameter
         };
         ThreadPool.QueueUserWorkItem(new WaitCallback(homegenie.RouteParameterChangedEvent), eventData);
         break;
     }
 }
Esempio n. 2
0
 public void ProcessRequest(MIGClientRequest request, MIGInterfaceCommand migCommand)
 {
     switch (migCommand.Command)
     {
     case "Events.Push":
         //TODO: implemet security and trust mechanism 
         var stream = new StreamReader(request.InputStream).ReadToEnd();
         var moduleEvent = JsonConvert.DeserializeObject<ModuleEvent>(
                               stream,
                               new JsonSerializerSettings(){ Culture = System.Globalization.CultureInfo.InvariantCulture }
                           );
         //
         // prefix remote event domain with HGIC:<remote_node_address>.<domain>
         moduleEvent.Module.Domain = "HGIC:" + request.RequestOrigin.Replace(".", "_") + "." + moduleEvent.Module.Domain;
         //
         var module = homegenie.Modules.Find(delegate(Module o)
         {
             return o.Domain == moduleEvent.Module.Domain && o.Address == moduleEvent.Module.Address;
         });
         if (module == null)
         {
             module = moduleEvent.Module;
             homegenie.Modules.Add(module);
         }
         else
         {
             Utility.ModuleParameterSet(module, moduleEvent.Parameter.Name, moduleEvent.Parameter.Value);
         }
             // "<ip>:<port>" remote endpoint port is passed as the first argument from the remote point itself
         module.RoutingNode = request.RequestOrigin + (migCommand.GetOption(0) != "" ? ":" + migCommand.GetOption(0) : "");
             //
         homegenie.LogBroadcastEvent(
             moduleEvent.Module.Domain,
             moduleEvent.Module.Address,
             request.RequestOrigin,
             moduleEvent.Parameter.Name,
             moduleEvent.Parameter.Value
         );
         HomeGenie.Service.HomeGenieService.RoutedEvent eventData = new HomeGenie.Service.HomeGenieService.RoutedEvent() {
             Sender = request.RequestOrigin,
             Module = module,
             Parameter = moduleEvent.Parameter
         };
         ThreadPool.QueueUserWorkItem(new WaitCallback(homegenie.RouteParameterChangedEvent), eventData);
         break;
     }
 }