Esempio n. 1
0
    /// <summary>
    /// If the event exists,invoke the event when server return messge.
    /// </summary>
    /// <param name="eventName"></param>
    /// <param name="value"></param>
    /// <returns></returns>
    ///
    public void InvokeOnEvent(ERequestTypes id, ICommand msg)
    {
        if (!this.eventMap.ContainsKey(id))
        {
            return;
        }

        List <Action <ICommand> > list = eventMap[id];

        foreach (Action <ICommand> action in list)
        {
            action.Invoke(msg);
        }
    }
Esempio n. 2
0
    //Adds the event to eventMap by name.
    public void AddOnEvent(ERequestTypes eventName, Action <ICommand> callback)
    {
        List <Action <ICommand> > list = null;

        if (this.eventMap.TryGetValue(eventName, out list))
        {
            list.Add(callback);
        }
        else
        {
            list = new List <Action <ICommand> >();
            list.Add(callback);
            this.eventMap.Add(eventName, list);
        }
    }
Esempio n. 3
0
 // 注册指定服务器推送消息
 public void Register(ERequestTypes eventId, Action <ICommand> action)
 {
     mEventManager.AddOnEvent(eventId, action);
 }
Esempio n. 4
0
    public void AddOnEvent <T>(Action <T> handler) where T : ICommand
    {
        ERequestTypes eventId = (ERequestTypes)Enum.Parse(typeof(ERequestTypes), "E" + typeof(T).Name);

        AddOnEvent(eventId, delegate(ICommand cmd) { handler((T)cmd); });
    }
Esempio n. 5
0
 // 注册指定服务器推送消息
 public void Register(ERequestTypes eventId, Action <ICommand> action)
 {
     mClient.Register(eventId, action);
 }