コード例 #1
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);
             }
         }
     }
 }
コード例 #2
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;
            //}
        }