private void AddProtocolProvider(string protocol, string nodeid, JObject data, Blade.Messages.AccessControl default_method_execute_access, Blade.Messages.AccessControl default_channel_broadcast_access, Blade.Messages.AccessControl default_channel_subscribe_access, int rank) { // @note this is ugly, locking, but it deals with a race condition on protocol removal lock (mProtocols) { Protocol proto = mProtocols.GetOrAdd(protocol, s => { OnProtocolAdd?.Invoke(mSession, protocol); Logger.LogInformation("Protocol added '{0}'", protocol); return(new Protocol() { Name = protocol, DefaultMethodExecuteAccess = default_method_execute_access, DefaultChannelBroadcastAccess = default_channel_broadcast_access, DefaultChannelSubscribeAccess = default_channel_subscribe_access }); }); Protocol.Provider provider = new Protocol.Provider() { NodeID = nodeid, Data = data, Rank = rank }; if (proto.InternalProviders.TryAdd(nodeid, provider)) { Logger.LogInformation("Protocol provider added '{0}' to '{1}'", nodeid, protocol); OnProtocolProviderAdd?.Invoke(mSession, proto, provider); } } }
private void AddProtocolUncertified(string protocol) { if (mProtocolsUncertified.TryAdd(protocol, true)) { Logger.LogInformation("Protocol added '{0}'", protocol); OnProtocolAdd?.Invoke(mSession, protocol); } }