private async void OnRequestReceived(AppServiceConnection sender, AppServiceRequestReceivedEventArgs args) { var message = args.Request.Message; string command = message["Command"] as string; switch (command) { case "Initialize": var messageDeferral = args.GetDeferral(); //Set a result to return to the caller var returnMessage = new ValueSet(); HttpServer server = new HttpServer(8000, appServiceConnection); IAsyncAction asyncAction = Windows.System.Threading.ThreadPool.RunAsync( (workItem) => { server.StartServer(); }); returnMessage.Add("Status", "Success"); var responseStatus = await args.Request.SendResponseAsync(returnMessage); messageDeferral.Complete(); break; case "Quit": //Service was asked to quit. Give us service deferral //so platform can terminate the background task serviceDeferral.Complete(); break; } }
private async void OnRequestReceived(AppServiceConnection sender, AppServiceRequestReceivedEventArgs args) { var message = args.Request.Message; string command = message["Command"] as string; switch (command) { case "Initialize": { var messageDeferral = args.GetDeferral(); //Set a result to return to the caller var returnMessage = new ValueSet(); HttpServer server = new HttpServer(8000, appServiceConnection); IAsyncAction asyncAction = Windows.System.Threading.ThreadPool.RunAsync( (workItem) => { server.StartServer(); }); returnMessage.Add("Status", "Success"); var responseStatus = await args.Request.SendResponseAsync(returnMessage); messageDeferral.Complete(); break; } case "Quit": { //Service was asked to quit. Give us service deferral //so platform can terminate the background task serviceDeferral.Complete(); break; } } }
//Processes message resquests sent from PoolWebService App private async void OnRequestReceived(AppServiceConnection sender, AppServiceRequestReceivedEventArgs args) { var message = args.Request.Message; string command = message["Command"] as string; switch (command) { case "Initialize": { Sensors.InitSensors(); Devices.InitDevices(); var messageDeferral = args.GetDeferral(); //Set a result to return to the caller var returnMessage = new ValueSet(); //Define a new instance of our HTTPServer on Port 8888 HttpServer server = new HttpServer(8888, appServiceConnection); IAsyncAction asyncAction = Windows.System.Threading.ThreadPool.RunAsync( (workItem) => { //Start the Sever server.StartServer(); }); //Respond back to PoolWebService with a Status of Success returnMessage.Add("Status", "Success"); var responseStatus = await args.Request.SendResponseAsync(returnMessage); messageDeferral.Complete(); break; } case "Quit": { //Service was asked to quit. Give us service deferral //so platform can terminate the background task serviceDeferral.Complete(); break; } } }