internal RobotHttpServer(int serverPort, HoloLensRobot bot) { this.bot = bot; sock = new StreamSocketListener(); sock.Control.KeepAlive = true; defaultPort = serverPort; sock.ConnectionReceived += async (s, e) => await ProcessRequestAsync(e.Socket); }
internal RobotHttpServer(int serverPort, HoloLensRobot bot) { this.bot = bot; sock = new StreamSocketListener(); sock.Control.KeepAlive = true; defaultPort = serverPort; sock.ConnectionReceived += async(s, e) => await ProcessRequestAsync(e.Socket); }
public void Run(IBackgroundTaskInstance taskInstance) { // Ensure our background task remains running taskDeferral = taskInstance.GetDeferral(); // Example: Create a timer-initiated ThreadPool task RobotStateTimer = ThreadPoolTimer.CreatePeriodicTimer(PopulateRobotStateData, TimeSpan.FromSeconds(TaskIntervalSeconds)); Bot = new HoloLensRobot(); // Start the server server = new RobotHttpServer(port, Bot); var asyncAction = ThreadPool.RunAsync((w) => { server.StartServer(); }); // Task cancellation handler, release our deferral there taskInstance.Canceled += OnCanceled; }