private void _BaseMethodsTest() { Console.WriteLine("BaseMethods test:"); using (Service svc = new Service("BaseMethodsTest")) { Console.WriteLine("DriveMode: {0}", svc.driveMode); Console.WriteLine("FPS: {0}", svc.fps); Console.WriteLine("frameInterval: {0}", svc.frameInterval); Console.WriteLine("isStarted: {0}", svc.isStarted); Console.WriteLine("svc type: {0}", svc.svcType); svc.fps = 1; Console.WriteLine("After set fps to 1, FPS: {0}, frameInterval: {1}", svc.fps, svc.frameInterval); try { svc.fps = LibConfig.commMaxServiceFPS + 10; } catch (Exception e) { Console.WriteLine("After set fps to {0}, exception occurred, right!", LibConfig.commMaxServiceFPS + 10); Console.WriteLine("exception:\n{0}", e); } } Console.WriteLine("Press any key to finish BaseMethods test..."); Console.ReadKey(); }
public void Run(string[] args) { Console.WriteLine("Core/Config/Ini test:"); using (var ini = new Ini()) { string file = "test_ini.ini"; Console.WriteLine("Load config file: {0}", file); ini.LoadFromFile(file); var helloSection = ini["Hello"]; Console.WriteLine("Hello section get: {0}", helloSection.sectionName); var unknownSection = ini.GetSection("sdfsafafas"); Console.WriteLine("Get not exist section, return: {0}", unknownSection); Console.WriteLine("[Hello] Cfg1 = {0}", ini.GetValue <int>("Hello", "Cfg1")); Console.WriteLine("[Hello] Cfg2 = {0}", ini.GetValue <string>("Hello", "Cfg2")); Console.WriteLine("[Hello] Cfg3 = {0}", ini.GetValue <string>("Hello", "Cfg3")); Console.WriteLine("[Hello] Cfg4 = {0}", ini.GetValue <bool>("Hello", "Cfg4")); Console.WriteLine("[World] Cfg1 = {0}", ini.GetValue <int>("World", "Cfg1")); Console.WriteLine("[World] Cfg2 = {0}", ini.GetValue <string>("World", "Cfg2")); Console.WriteLine("[World] Cfg3 = {0}", ini.GetValue <string>("World", "Cfg3")); Console.WriteLine("[World] Cfg4 = {0}", ini.GetValue <bool>("World", "Cfg4")); } Console.WriteLine("Press any key to exit..."); Console.ReadKey(); }
public override void OnIdle(int idleTime) { if (_idleOutputTimes == 5) { return; } Console.WriteLine("Service [{0}] idle, idleTime: {1}", svc.svcName, idleTime); _idleOutputTimes += 1; }
public override void OnUpdate() { if (_updateOutputTimes == 5) { return; } Console.WriteLine("Service [{0}] update", svc.svcName); _updateOutputTimes += 1; }
public void Run(string[] args) { Console.WriteLine("Timer test:"); using (Service svc = new Service("TimerTestSvc")) { svc.Start(); Console.WriteLine("Press any key to pause TimerTest..."); Console.ReadKey(); } }
public void Run(string[] args) { Console.WriteLine("Comm/Service test:"); // _BaseMethodsTest(); _StartStopTest(); // _ListenTest(); // _ConnectTest(); // _SendRecvTest(); // _PreHandleTest(); // _PacketExcTest(); // _FrameExcTest(); // _ExternalDriveTest(); Console.WriteLine("Press any key to exit..."); Console.ReadKey(); }
public void Run(string[] args) { Console.WriteLine("Core/Log/Logger test:"); string logCfg = "Logger_Cfg.cfg"; LoggerMgr.Init(logCfg); // Test Root logger. Log.enabledLogFileInfo = true; Log.Dbg("A debug message from Log.Dbg()..."); Log.Info("A info message from Log.Info()..."); Log.Warn("A warn message from Log.Warn()..."); Log.Err("A error message from Log.Err()..."); Log.Fatal("A fatal message from Log.Fatal()..."); Log.Dbg <Log>("A debug message from Log.Dbg<Log>()..."); Log.Info <Log>("A debug message from Log.Dbg<Log>()..."); Log.Warn <Log>("A debug message from Log.Dbg<Log>()..."); Log.Err <Log>("A debug message from Log.Dbg<Log>()..."); Log.Fatal <Log>("A debug message from Log.Dbg<Log>()..."); // Get test logger to test. var testLogger = LoggerMgr.Get("test"); testLogger.Dbg("A debug message from testLogger.Dbg()..."); testLogger.Info("A info message from testLogger.Info()..."); testLogger.Warn("A warn message from testLogger.Warn()..."); testLogger.Err("A error message from testLogger.Err()..."); testLogger.Fatal("A fatal message from testLogger.Fatal()..."); Console.WriteLine("Press any key to exit test..."); Console.ReadKey(); LoggerMgr.Destroy(); }
private void _StartStopTest() { Console.WriteLine("Start/Stop service test:"); using (Service svc = new Service("StartStopTest")) { svc.Start(); Console.WriteLine("Start service, wait 2 seconds..."); Thread.Sleep(2000); Console.WriteLine("Stop service..."); svc.Stop(); Console.WriteLine("ReStart service..."); svc.Start(2); Thread.Sleep(5000); Console.WriteLine("Stop service..."); svc.Stop(); } Console.WriteLine("Press any key to finish Start/Stop service test..."); Console.ReadKey(); }
public override void OnInit() { Console.WriteLine("Service {0} init(By Facade)", svc.svcName); throw new Exception("Test Exception throw by OnInit!!!"); }
public override void OnAsyncConnResult(AsyncConnResult asyncConnResult) { Console.WriteLine("Async-Connect result: {0}", asyncConnResult); }
public bool OnUnifyPrePacket(Packet packet) { Console.WriteLine("OnUnifyPrePacket: {0}", packet); return(true); }
public override void OnDestroy() { Console.WriteLine("Service[{0}] destroy", svc); }
public override void OnDestroy() { Console.WriteLine("Service {0} destroy(By Facade2)", svc.svcName); }
public void OnHandle(Packet packet) { Console.WriteLine("OnHandle, packet: {0}", packet); }
public bool OnPreHandle(Packet packet) { Console.WriteLine("OnPreHandle, packet: {0}", packet); return(true); }
public void OnBroadcastPacket(Packet packet) { Console.WriteLine("Recv broadcast packet: {0}", packet); }
public void OnMulticastPacket(Packet packet) { Console.WriteLine("Recv multicast-packet: {0}", packet); }
public override void OnUnHandledPacket(Packet packet) { Console.WriteLine("UnHandled packet: {0}", packet); }
public override void OnProtoReport(ProtoReport report) { Console.WriteLine("Proto report: {0}", report); }
public void OnFrameExc(Service svc, Exception e) { Console.WriteErrorLine("Service {0} exception raised, exception: {1}", svc.svcName, e); }
public override void OnInit() { Console.WriteLine("Service {0} init(By Facade2)", svc.svcName); }
public override void OnSessionDestroy(SessionDestroyInfo destroyInfo) { Console.WriteLine("Session destroy: {0}", destroyInfo); }
public override void OnInit() { Console.Write("Service[{0}] init", svc); }
private void _OnTimeout(Timer timer) { Console.WriteLine("Timeout handler called!"); }
private void OnPacket(Packet packet) { Console.WriteLine("Recv packet: {0}", packet); }
public void OnFrameException(Service svc, Exception e) { Console.WriteLine("Frame exception: {0}", e); }
public void OnPacket(Packet packet) { Console.WriteLine("OnPacket: {0}", packet); throw new Exception("Test exception, Yep!"); }
public override void OnSessionCreate(SessionInfo sessionInfo) { Console.WriteLine("New session create: {0}", sessionInfo); }
private void _OnCancel(Timer timer) { Console.WriteLine("Timer cancel handler called!"); }
public void OnPacketExcHandler(PacketExceptionInfo excInfo) { Console.WriteLine("Packet exception, phase: {0}, packet: {1}, e: {2}", excInfo.phase, excInfo.packet, excInfo.exception); }