public Task <ILazySocketMessageChannel> TryGetMessageChannelAsync(ulong channelId) { if (MessageChannels.TryGetValue(channelId, out var result)) { return(Task.FromResult(result)); } return(Task.FromResult <ILazySocketMessageChannel>(null)); }
public MessageChannel GetChannelByName(string name) { int chId = 0; if (MessageChannels.TryGetValue(name, out chId)) { return(MChannelsList[chId]); } return(null); }
/// <summary> /// assume now for one message type we have only one channel /// </summary> /// <param name="channelName"></param> /// <param name="m"></param> /// <param name="moduleName">For exception information if occured model conflicts</param> public void AssignMessageTypeToChannel(string channelName, TItemModel m, string moduleName) { int v; if (MessageChannels.TryGetValue(channelName, out v)) { MessageChannel channel = MChannelsList[v]; if (channel.AssignedMessageModel == null) { channel.FirstModuleNameAssigned = moduleName; channel.AssignedMessageType = m.ItemTypeName; channel.AssignedMessageModel = m; //if (!MessageTypes.ContainsKey(m.ItemTypeName)) MessageTypes.Add(m.ItemTypeName, v); } } else { throw new Exception("Error: assign message type model to channel: channel name " + channelName + "not exists"); } }