Exemplo n.º 1
0
    public static bool DelRespCb(int cmd, NetRespCb netRespCb = null)
    {
        if (!_DictRespCb.TryGetValue((int)cmd, out var list))
        {
            return(false);
        }
        if (_CallCmd == cmd)
        {
            var data = new CmdCbData();
            data.cmd = cmd;
            data.cb  = netRespCb;
            _DeleteQueue.Enqueue(data);
            return(true);
        }

        if (netRespCb == null)
        {
            _DictRespCb.Remove(cmd);
            return(true);
        }

        if (list.RemoveAll(m => m == netRespCb) > 0)
        {
            if (list.Count == 0)
            {
                _DictRespCb.Remove(cmd);
            }
            return(true);
        }
        return(false);
    }
Exemplo n.º 2
0
 public static bool AddRespCb(int cmd, NetRespCb netRespCb)
 {
     if (!_DictRespCb.TryGetValue((int)cmd, out var list))
     {
         list = new List <NetRespCb>();
         _DictRespCb.Add(cmd, list);
     }
     if (list != null)
     {
         list.Add(netRespCb);
     }
     return(true);
 }
Exemplo n.º 3
0
 public static void RegitDefaultListener(NetRespCb callback)
 {
     _DefaultCb += callback;
 }