Esempio n. 1
0
        public void AddSockUnit(SockUnit unit)
        {
            System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() =>
            {
                switch (unit.Type)
                {
                case SockType.listen:
                case SockType.connect:
                    SockUnitGroup.Add(unit);
                    break;

                case SockType.accept:
                    var subset = from s in SockUnitGroup
                                 where s.Type == SockType.listen && s.Lep.Port == unit.Lep.Port
                                 select s;
                    if (subset.Count() != 0)
                    {
                        subset.First().Childs.Add(unit);
                        CurrentAcceptCount++;
                        HistoryAcceptOpenCount++;
                    }
                    break;
                }
            }));
        }
Esempio n. 2
0
        public void DelSockUnit(SockType type, IPEndPoint lep, IPEndPoint rep)
        {
            System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() =>
            {
                SockUnit unit = FindSockUnit(type, lep, rep);
                if (unit == null)
                {
                    return;
                }

                switch (type)
                {
                case SockType.listen:
                case SockType.connect:
                    SockUnitGroup.Remove(unit);
                    break;

                case SockType.accept:
                    var subset = from s in SockUnitGroup
                                 where s.Type == SockType.listen && s.Lep.Port == unit.Lep.Port
                                 select s;
                    if (subset.Count() != 0)
                    {
                        subset.First().Childs.Remove(unit);
                        CurrentAcceptCount--;
                        HistoryAcceptCloseCount++;
                    }
                    break;
                }
            }));
        }
Esempio n. 3
0
 public void CloseSockUnit(SockType type, IPEndPoint lep, IPEndPoint rep)
 {
     System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() => {
         SockUnit unit = FindSockUnit(type, lep, rep);
         if (unit != null)
         {
             unit.State = SockState.Closed;
         }
     }));
 }
Esempio n. 4
0
 public void CloseSockUnit(string id)
 {
     System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() => {
         SockUnit unit = FindSockUnit(id);
         if (unit == null)
         {
             return;
         }
         unit.State = SockState.Closed;
     }));
 }
Esempio n. 5
0
 public void OpenSockUnit(SockType type, IPEndPoint lep, IPEndPoint rep, string sessid)
 {
     System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() => {
         SockUnit unit = FindSockUnit(type, lep, rep);
         if (unit == null)
         {
             return;
         }
         unit.Lep    = lep;
         unit.Rep    = rep;
         unit.SESSID = sessid;
         unit.State  = SockState.Opened;
     }));
 }