Esempio n. 1
0
 public override void Init(ITorchBase torch)
 {
     base.Init(torch);
     SetupConfig();
     Instance       = this;
     SessionManager = Torch.Managers.GetManager <TorchSessionManager>();
     SessionManager.SessionStateChanged += SessionManagerOnSessionStateChanged;
 }
Esempio n. 2
0
        private static void ProcessRequest(HttpListenerContext context)
        {
            using (var response = context.Response)
            {
                try
                {
                    var handled = false;
                    switch (context.Request.Url.AbsolutePath)
                    {
                    case "/json":
                        switch (context.Request.HttpMethod)
                        {
                        case "GET":

                            if (Koth.Instance.Config.ApiEnabled)
                            {
                                response.ContentType = "application/json";
                                var data         = Koth.ScoresFromStorage();
                                var responseBody = JsonConvert.SerializeObject(data);
                                var buffer       = Encoding.UTF8.GetBytes(responseBody);
                                response.ContentLength64 = buffer.Length;
                                response.OutputStream.Write(buffer, 0, buffer.Length);
                                handled = true;
                                break;
                            }

                            else
                            {
                                break;
                            }
                        }

                        break;


                    case "/koth":
                        switch (context.Request.HttpMethod)
                        {
                        case "GET":
                            if (Koth.Instance.Config.WebPageEnabled)
                            {
                                var kothdata = Koth.ScoresFromStorage();
                                var data     = Encoding.UTF8.GetBytes(PageHtml.Replace("REPLACEMEYES",
                                                                                       JsonConvert.SerializeObject(kothdata)));
                                response.ContentType     = "text/html";
                                response.ContentEncoding = Encoding.UTF8;
                                response.ContentLength64 = data.LongLength;
                                response.OutputStream.Write(data, 0, data.Length);
                                handled = true;
                                break;
                            }

                            else
                            {
                                break;
                            }
                        }

                        break;
                    }

                    if (!handled)
                    {
                        response.StatusCode = 404;
                    }
                }
                catch (Exception e)
                {
                    response.StatusCode  = 500;
                    response.ContentType = "application/json";
                    var buffer = Encoding.UTF8.GetBytes("{\"msg\": 500}");
                    response.ContentLength64 = buffer.Length;
                    response.OutputStream.Write(buffer, 0, buffer.Length);
                    Log.Error(e, "Server error");
                }
            }
        }
 public KothPluginControl(Koth plugin) : this()
 {
     Plugin      = plugin;
     DataContext = plugin.Config;
 }
 private void RefreshPathButton_OnClick(object sender, RoutedEventArgs e)
 {
     Log.Info("Path Refresh");
     Koth.SetPath();
 }
Esempio n. 5
0
 public void PathRefresher()
 {
     this.Context.Respond("Save Path Refreshed");
     Koth.SetPath();
 }