public void Listen <T>(uint protocolId, ProtobufCallback <T> callback) where T : IExtensible { Delegate listener; if (listeners.TryGetValue(protocolId, out listener)) { listeners[protocolId] = Delegate.Combine(listener, callback); } else { listeners[protocolId] = callback; } }
public void Unlisten <T>(uint protocolId, ProtobufCallback <T> callback) where T : IExtensible { Delegate listener; if (listeners.TryGetValue(protocolId, out listener)) { listener = Delegate.Remove(listener, callback); if (listener == null) { listeners.Remove(protocolId); } else { listeners[protocolId] = listener; } } }