using System.Net; using System.Diagnostics; using Sog; namespace SMAgent { public static class SMAgentUtils { private static ServerApp m_app; private static PacketSender m_packetSender; public static SMAgentConfig Config; public static string HostName { get; private set; } public static void Init(ServerApp app) { m_app = app; m_packetSender = new PacketSender(); HostName = Dns.GetHostName(); TraceLog.Trace("SMAgentUtils.Init name {0} center ip {1}", HostName, Config.centerip); } public static ProtoBufPacker GetProtoPacker() { return ProtoPackerFactory.Instance.GetProtoBufPacker(); } public static PacketSender GetPacketSender() { return m_packetSender; } public static long GetTimeMs() { return m_app.Time.GetTime(); } public static long GetTimeSecond() { return m_app.Time.GetTimeSecond(); } public static uint GetAppID() { return m_app.ServerID; } public static ServerApp GetApp() { return m_app; } public static void StartProcess(string filename, string workpath, string param) { ProcessStartInfo startInfo = new ProcessStartInfo(filename, param); startInfo.CreateNoWindow = true; startInfo.WorkingDirectory = workpath; //startInfo.UseShellExecute = true; //开启子进程 using (Process proc = new Process()) { proc.StartInfo = startInfo; proc.EnableRaisingEvents = true; proc.Start(); } } } }