Exemplo n.º 1
0
 public void FireEvent(T cmd, byte[] proto = null)
 {
     if (events != null)
     {
         NetEventsWarp warp = null;
         if (events.TryGetValue(cmd, out warp))
         {
             if (warp.cbs != null)
             {
                 warp.cbs(proto);
             }
         }
     }
 }
Exemplo n.º 2
0
 public void RemoveEvent(T cmd, ProtoCallBack cb)
 {
     if (events != null)
     {
         NetEventsWarp warp = null;
         if (events.TryGetValue(cmd, out warp))
         {
             warp.cbs -= cb;
             if (warp.cbs == null)
             {
                 events.Remove(cmd);
             }
         }
     }
 }
Exemplo n.º 3
0
    public Action AddEvent(T cmd, ProtoCallBack cb)
    {
        if (events == null)
        {
            events = new Dictionary <T, NetEventsWarp>();
        }
        NetEventsWarp warp = null;

        if (events.TryGetValue(cmd, out warp))
        {
            warp.cbs += cb;
        }
        else
        {
            events.Add(cmd, new NetEventsWarp(cb));
        }
        return(() =>
        {
            RemoveEvent(cmd, cb);
        });
    }