public void UnregisterProto(int id, OnReceiveProtoDlg callback) { if (_protoID2CallbackListDict[id] != null) { _protoID2CallbackListDict[id].Remove(callback); } }
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; } } }
public void RegisterProto(int id, OnReceiveProtoDlg callback) { if (callback == null) { return; } if (!_protoID2CallbackListDict.ContainsKey(id)) { _protoID2CallbackListDict[id] = new List <OnReceiveProtoDlg>(); } _protoID2CallbackListDict[id].Add(callback); }