public override void Process(Args args)
        {
            string command = args[0].ToString();

            ProgramLog.Log("Web command `{0}` from {1}", command, args.IpAddress);
            Program.commandParser.ParseAndProcess(args.WebKit.WebSender, command);
        }
 public override void Process(Args args)
 {
     var player = Terraria_Server.Server.GetPlayerByName(args[0].ToString());
     if (player == null)
         Data["data"] = "Player is no longer online.";
     else
         Data["data"] = UserMoniter.SerializePlayer(player);
 }
Exemple #3
0
        public override void Process(Args args)
        {
            var message = args[0].ToString().Trim();

            //if (msg.Contains("="))

            var logger = (SendingLogger)SendingLoggerExtension.WEB;
            Terraria_Server.Server.notifyAll("Web: " + message, true, logger);
        }
Exemple #4
0
        public override void Process(Args args)
        {
            if (args.Count == 0 || args[0].ToString() == "undefined")
            {
                Data["messages"] = args.WebKit.UserChat.Values;
                Data["timesent"] = DateTime.Now.ToBinary().ToString();
                return;
            }

            string timeStamp = args[0].ToString();
            if (timeStamp.Trim().Length == 0)
            {
                timeStamp = (-long.MaxValue).ToString();
            }

            var chatList = Json.GetUserChat(timeStamp, args.WebKit);
            if (chatList != null)
            {
                Data["messages"] = chatList;
                Data["timesent"] = DateTime.Now.ToBinary().ToString();
            }
        }
Exemple #5
0
        public override void Process(Args args)
        {
            var process = System.Diagnostics.Process.GetCurrentProcess();
            var time = process.TotalProcessorTime;

            Data["status"] = args.WebKit.ServerStatus;
            Data["time"] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            Data["users"] = Terraria_Server.Networking.ClientConnection.All.Count;
            Data["maxusers"] = SlotManager.MaxSlots;
            Data["userlist"] = Json.GetUserList();
            //Data["ready"] = NetPlay.ServerUp;

            Data["cpu"] = String.Format("{0:0.00}% ({1})",
                SystemStats.GetCpuUsage(), time);

            Data["virmem"] = String.Format("{0:0.0}/{1:0.0}MB",
                process.VirtualMemorySize64 / 1024.0 / 1024.0,
                process.PeakVirtualMemorySize64 / 1024.0 / 1024.0);

            Data["phymem"] = String.Format("{0:0.0}/{1:0.0}MB",
                SystemStats.GetMemoryUsage() / 1024.0 / 1024.0,
                process.PeakWorkingSet64 / 1024.0 / 1024.0);
        }
Exemple #6
0
        public static void ParseAndProcess(WebKit webKit, HttpListenerContext context, string[] args, string user, string ipAddress)
        {
            try
            {
                if (args != null && args.Length > 0)
                {
                    //paremeters.Clear();

                    string id = args.ElementAt(0).Trim();

                    if (id != null && id.Length > 0)
                    {
                        RemoveFirst(ref args);

                        for (var i = 0; i < args.Length; i++)
                        {
                            var arg = args[i].ToString();
                            if (arg.Length > 0)
                            {
                                if (arg.Contains('='))
                                    arg = arg.Remove(0, arg.IndexOf('=') + 1).Trim();

                                if (arg.Length > 0)
                                    args[i] = arg;
                            }
                        }

                        var arguments = new Args()
                        {
                            Arguments = args,
                            AuthName = user,
                            IpAddress = ipAddress,
                            WebKit = webKit
                        };

                        //InsertAtFirst(
                        //Data.Insert(0, IPAddress);

                        //foreach (string param in Data)
                        //{
                        //    string parameter = param.Trim();
                        //    if (parameter.Length > 0)
                        //    {
                        //        if (parameter.Contains('='))
                        //        {
                        //            parameter = parameter.Remove(0, parameter.IndexOf('=') + 1);
                        //        }
                        //        paremeters.Add(parameter);
                        //    }
                        //}

                        //paremeters.Insert(0, WebKit);

                        //var args = new Args()
                        //{
                        //    WebKit = WebKit,
                        //    Sender = new Utility.WebSender(
                        //};

                        var serialized = ProcessPacket(id, arguments);
                        context.WriteString(String.Empty, serialized);
                    }
                }
            }
            catch (ExitException) { throw; }
            catch (HttpListenerException) { }
            catch (ArgumentException) { }
            catch (Exception e)
            {
                ProgramLog.Log(e);
            }
        }
Exemple #7
0
        public static string ProcessPacket(string id, Args args)
        {
            try
            {
                foreach (SerializablePacket packet in Packets.Where(x => x.GetPacket().ToString().ToLower().Equals(id.ToLower())))
                {
                    packet.Process(args);
                    return packet.ToJson();
                }
            }
            catch (ExitException) { throw; }
            catch (Exception e)
            {
                ProgramLog.Log(e);
            }

            return null;
        }
Exemple #8
0
 public override void Process(Args args)
 {
     var webKit = args.WebKit;
     Data["maxLines"] = webKit.Properties.MaxChatLines;
     Data["main-interval"] = webKit.MainUpdateInterval;
 }
Exemple #9
0
 public abstract void Process(Args args);
Exemple #10
0
 public override void Process(Args args)
 {
     ThreadPool.QueueUserWorkItem(Processor, args);
 }