public void RegisterHandler(MessageProcessUnitBase module, int noticeID, NotificationHandlerDelegate handler) { if (module != null && handler != null) { NotificationHandler notificationHandler = new NotificationHandler(noticeID, handler); CollectionUtil.AddIntoTable(noticeID, notificationHandler, notificationHandlerTable); CollectionUtil.AddIntoTable(module, noticeID, notificationHandler, moduleNotificationRegisterTable); #if UNITY_EDITOR if (LogUtil.ShowDebug != null) { LogUtil.ShowDebug(string.Format("[本地通知中心]1.注册通知处理器:来自[{0}] 通知ID[{1}] 处理回调[{2}]", module.GetType().Name, noticeID, StringUtility.ToString(handler))); } #endif } #if UNITY_EDITOR else { if (LogUtil.ShowError != null) { LogUtil.ShowError(string.Format("注册通知处理器时传递的参数有[null]值:通知ID[{0}] 模块[{1}] 处理回调[{2}]", noticeID, StringUtility.ToString(module), StringUtility.ToString(handler))); } } #endif }
internal void AddHandler(Handlers handlers, Type type, MethodInfo method, string rpcMethod) { if (Reflector.IsRequestHandler(method)) { RequestHandlerDelegate requestHandlerDelegate = Reflector.CreateRequestHandlerDelegate(type, method, this); RequestHandler requestHandler = new RequestHandler(rpcMethod, Reflector.GetRequestType(method), Reflector.GetResponseType(method), requestHandlerDelegate); handlers.AddRequestHandler(requestHandler); } else if (Reflector.IsNotificationHandler(method)) { NotificationHandlerDelegate notificationHandlerDelegate = Reflector.CreateNotificationHandlerDelegate(type, method, this); NotificationHandler notificationHandler = new NotificationHandler(rpcMethod, Reflector.GetNotificationType(method), notificationHandlerDelegate); handlers.AddNotificationHandler(notificationHandler); } }
protected void TryRegisterNotificationHandler(int noticeID, NotificationHandlerDelegate handler) { if (handler != null) { // Register to notification central hub NotificationCentralHub.Instance.RegisterHandler(this, noticeID, handler); } #if UNITY_EDITOR else { if (LogUtil.ShowError != null) { LogUtil.ShowError(string.Format("模块[{0}]注册通知的调用中有无效参数:通知ID[{1}] 监视器委托[{2}]", GetType().Name, noticeID, StringUtility.ToString(handler))); } } #endif }
internal NotificationHandler(string rpcMethod, Type notificationType, NotificationHandlerDelegate handler) { RpcMethod = rpcMethod; NotificationType = notificationType; this.handler = handler; }
internal NotificationHandler(string rpcMethod, Type notificationType, NotificationHandlerDelegate handler) { _rpcMethod = rpcMethod; _notificationType = notificationType; _handler = handler; }
internal NotificationHandler(int noticeID, NotificationHandlerDelegate handler) { this.noticeID = noticeID; this.handler = handler; this.isActivated = true; }