Пример #1
0
 /// <summary>
 /// Asks the user which listener to delete.
 /// </summary>
 public void DelListener(string id)
 {
     //Console.WriteLine("Please enter the ID of the listener you want to delete:\r\n (use the 'listlisteners' command to show all the listener IDs)");
     if (id != "")
     {
         try {
             ListenEntry le = new ListenEntry();
             le.guid = new Guid(id);
             if (!Listeners.Contains(le))
             {
                 Console.WriteLine("Specified ID not found in list!");
                 return;
             }
             else
             {
                 this[Listeners.IndexOf(le)].Dispose();
                 Listeners.Remove(le);
                 Config.SaveData();
             }
         } catch {
             Console.WriteLine("Invalid ID tag!");
             return;
         }
         Console.WriteLine("Listener removed from the list.");
     }
 }
Пример #2
0
 public void Leave(string connectionId)
 {
     lock (Loginstate)
     {
         var index = Feeders.IndexOf(connectionId);
         if (index != -1)
         {
             Feeders.Remove(connectionId);
         }
         else
         {
             index = Listeners.IndexOf(connectionId);
             if (index != -1)
             {
                 Listeners.Remove(connectionId);
             }
         }
     }
 }
Пример #3
0
        public bool Join(HubType groupName, string connectionId)
        {
            lock (Loginstate)
            {
                switch (groupName)
                {
                case HubType.Feeder:
                    Groups.Add(connectionId, HubType.Feeder.ToString());
                    if (Feeders.IndexOf(connectionId) == -1)
                    {
                        Feeders.Add(connectionId);
                        return(true);
                    }
                    break;

                case HubType.Listener:
                    Groups.Add(connectionId, HubType.Listener.ToString());
                    if (Listeners.IndexOf(connectionId) == -1)
                    {
                        Listeners.Add(connectionId);
                        return(true);
                    }
                    break;
                }
                return(false);
            }

            //if (Connections[connectionId] == null)
            //{
            //    Groups.Add(connectionId, groupName.ToString());
            //    Connections.Add(new Connection(connectionId, groupName), new TimeSpan(20, 0, 0));
            //    return true;
            //}
            //else
            //{
            //    return false;
            //}
        }