/// <summary> /// 发送系统请求 /// </summary> /// <param name="sys"></param> /// <param name="controller"></param> /// <param name="str"></param> public void SendSys(GameSys sys, MethodController controller, string str) { string strByte = string.Format("{0}|{1}|{2}", ((int)sys).ToString(), ((int)controller).ToString(), str); Debug.Log(strByte); ClientSoc.Send(Tool.GetBytes(strByte)); }
public void SelectController(Client client, GameSys sys, MethodController controller, string data) { BaseController currentController = null; Console.WriteLine("控制器:" + sys.ToString()); Console.WriteLine("执行方法:" + controller.ToString()); //Console.WriteLine("接受到的数据:" + data); if (ControllerDic.ContainsKey(sys)) { currentController = ControllerDic[sys]; } else { Console.WriteLine("传递过来的控制器不纯在" + sys); } MethodInfo mt = currentController.GetType().GetMethod(controller.ToString()); if (mt == null) { Console.WriteLine("要执行的方法不存在" + controller.ToString()); } object[] go = new object[] { client, data }; Console.WriteLine(currentController.ToString() + go.ToString()); mt.Invoke(currentController, go); //object returnObj = //if (returnObj ==null) //{ // Console.WriteLine("不需要返回数据"); //} //else //{ // client.SendMassageSys(returnObj.ToString()); //} }
public void index_get_system_methods() { var systemApp1 = new Domain.Entities.System() { SystemId = 1, Name = "App 1" }; var systemApp2 = new Domain.Entities.System() { SystemId = 2, Name = "App 2" }; _systemRepository.Add(systemApp1); _systemRepository.Add(systemApp2); var controller = new MethodController(_repository, _systemRepository); _repository.Add(new Method() { MethodId = 1, Name = "MethodOneInApp1", SystemId = 1 }); _repository.Add(new Method() { MethodId = 2, Name = "MethodOne", SystemId = 2 }); _repository.Add(new Method() { MethodId = 3, Name = "MethodTwo", SystemId = 2 }); _repository.Add(new Method() { MethodId = 4, Name = "MethodThree", SystemId = 2 }); var result = controller.Index(systemApp2.SystemId); result.Should().BeViewResult().ModelAs <IEnumerable <Method> >().Should().HaveCount(3); result.Should() .BeViewResult() .ModelAs <IEnumerable <Method> >() .First(p => p.MethodId == 3) .Name.Should() .Be("MethodTwo"); }
public void ReceptionData(GameSys sys, MethodController controller, string str) { MainServer.ReceiveMessage(this, sys, controller, str); }