コード例 #1
0
        public bool RemoveTopic(Guid pubOwner, string topicName)
        {
            if (!_topicDictionary.TryGetValue(pubOwner, out Dictionary <string, Topic> pubTopicDictionary))
            {
                return(false);
            }

            if (pubTopicDictionary.ContainsKey(topicName))
            {
                Topic topic = pubTopicDictionary[topicName];
                topic.SendMessage(new MessagePacket(PacketTypes.PrintData, new string[] {
                    $"The topic named '{topic.Name}' has been deleted and you will no longer recieve messages from it."
                }));
                topic.ClearSubscribers();

                pubTopicDictionary.Remove(topicName);
                return(true);
            }
            return(false);
        }