Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        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);
        }