public IHttpContext KeyboardStart(IHttpContext ctx) { Program.KeyboardMapperInstance.Start(); RestServer.SetCORSHeaders(ctx); RestServer.CloseResponse(ctx); return(ctx); }
public IHttpContext ControllerStart(IHttpContext ctx) { Program.ControllerManagerInstance.Start(); RestServer.SetCORSHeaders(ctx); RestServer.CloseResponse(ctx); return(ctx); }
public IHttpContext KeyboardGetMapping(IHttpContext ctx) { RestServer.SetCORSHeaders(ctx); RestServer.SendJsonResponse(ctx, new Dictionary <string, object> { { "currentMapping", Program.KeyboardMapperInstance.CurrentMappingName }, { "mappings", Program.KeyboardMapperInstance.GetAllMappings() }, }); return(ctx); }
public IHttpContext Status(IHttpContext ctx) { RestServer.SetCORSHeaders(ctx); RestServer.SendJsonResponse(ctx, new Dictionary <string, object> { { "isControllerRunning", Program.ControllerManagerInstance.IsRunning }, { "isKeyboardRunning", Program.KeyboardMapperInstance.IsRunning }, { "hostname", System.Net.Dns.GetHostName() }, }); return(ctx); }
public IHttpContext KeyboardMappingOptions(IHttpContext ctx) { var validMethods = new HttpMethod[] { HttpMethod.GET, HttpMethod.POST, HttpMethod.DELETE, HttpMethod.OPTIONS, }; ctx.Response.Headers["Access-Control-Allow-Methods"] = string.Join(", ", validMethods.Select(x => x.ToString())); RestServer.SetCORSHeaders(ctx); RestServer.CloseResponse(ctx); return(ctx); }
public IHttpContext KeyboardSetCurrentName(IHttpContext ctx) { try { Program.KeyboardMapperInstance.SetCurrentMappingName(ctx.Request.Payload); RestServer.SetCORSHeaders(ctx); RestServer.CloseResponse(ctx); } catch (System.Exception e) { ctx.Response.StatusCode = HttpStatusCode.InternalServerError; RestServer.SendJsonResponse(ctx, new Dictionary <string, object> { { "error", e.Message }, }); } return(ctx); }
public IHttpContext KeyboardRenameMapping(IHttpContext ctx) { try { var json = RestServer.ParseJson(ctx.Request.Payload); Program.KeyboardMapperInstance.RenameMapping((string)json["name"], (string)json["newName"]); RestServer.SetCORSHeaders(ctx); RestServer.CloseResponse(ctx); } catch (System.Exception e) { ctx.Response.StatusCode = HttpStatusCode.InternalServerError; RestServer.SendJsonResponse(ctx, new Dictionary <string, object> { { "error", e.Message }, }); } return(ctx); }