public void HandleRequest(MainPack pack, LanClient client) { if (controllerDict.TryGetValue(pack.Requestcode, out BaseController controller)) { string methodName = pack.Actioncode.ToString(); MethodInfo method = controller.GetType().GetMethod(methodName); if (method == null) { Console.WriteLine("找不到方法 {0}", methodName); return; } object[] o = new object[] { client, pack }; object ret = method.Invoke(controller, o); if (ret == null) { return; } client.Send(ret as MainPack); } else { Console.WriteLine("找不到負責處理的 controller"); } }
public MainPack Logon(LanClient client, MainPack pack) { if (client.Logon(pack)) { pack.Returncode = ReturnCode.Success; } else { pack.Returncode = ReturnCode.Fail; } return(pack); }
public void HandleRequest(MainPack pack, LanClient lanClient) { controllerManager.HandleRequest(pack, lanClient); }