Ejemplo n.º 1
0
 public void UnregisterProto(int id, OnReceiveProtoDlg callback)
 {
     if (_protoID2CallbackListDict[id] != null)
     {
         _protoID2CallbackListDict[id].Remove(callback);
     }
 }
Ejemplo n.º 2
0
 public void FixedUpdate()
 {
     while (true)
     {
         if (msgQueue.Count > 0)
         {
             lock (msgQueue)
             {
                 MSG msg = msgQueue.Dequeue();
                 Debug.Log(msg.Protocol_Id);
                 if (_protoID2CallbackListDict.ContainsKey(msg.Protocol_Id) && _protoID2CallbackListDict[msg.Protocol_Id] != null)
                 {
                     for (int i = 0; i < _protoID2CallbackListDict[msg.Protocol_Id].Count; ++i)
                     {
                         OnReceiveProtoDlg tempCallback = _protoID2CallbackListDict[msg.Protocol_Id][i];
                         tempCallback(msg.Data);
                     }
                 }
             }
         }
         else
         {
             break;
         }
     }
 }
Ejemplo n.º 3
0
    public void RegisterProto(int id, OnReceiveProtoDlg callback)
    {
        if (callback == null)
        {
            return;
        }

        if (!_protoID2CallbackListDict.ContainsKey(id))
        {
            _protoID2CallbackListDict[id] = new List <OnReceiveProtoDlg>();
        }

        _protoID2CallbackListDict[id].Add(callback);
    }