static async Task <MessageResponse> ModuleLoadedMessageHandler(Message msg, object ctx) { AzureModule module = (AzureModule)ctx; var msgBytes = msg.GetBytes(); var msgString = Encoding.UTF8.GetString(msgBytes); Log.WriteLine("loadModule msg received: '{0}'", msgString); var loadMsg = JsonConvert.DeserializeObject <ModuleLoadedMessage>(msgString); await module.ProcessModuleLoadedMessage(loadMsg); return(MessageResponse.Completed); }
private async Task <MethodResponse> SetModuleLoaded(MethodRequest req, object context) { string data = Encoding.UTF8.GetString(req.Data); Log.WriteLine("Direct Method SetModuleLoaded {0}", data); var loadMsg = JsonConvert.DeserializeObject <ModuleLoadedMessage>(data); AzureModule module = (AzureModule)context; await module.ProcessModuleLoadedMessage(loadMsg); // Acknowlege the direct method call with a 200 success message string result = "{\"result\":\"Executed direct method: " + req.Name + "\"}"; return(new MethodResponse(Encoding.UTF8.GetBytes(result), 200)); }