Exemplo n.º 1
0
        public Socket Connect(EndPoint EndPoint, System.Action <bool> Result)
        {
            Socket rudpSocket = null;

            System.Action <Line> handler = Stream =>
            {
                var connecter = new PeerConnecter(Stream);
                connecter.TimeoutEvent += () => { Result(obj: false); };
                connecter.DoneEvent    += () => { Result(obj: true); };

                var p = new Socket(Stream, connecter);
                p.CloseEvent += () => { Remove(p); };

                lock (m_Peers)
                {
                    m_Peers.Add(Stream.EndPoint, p);
                }

                m_Updater.Add(p);
                rudpSocket = p;
            };

            lock (m_WiringOperator)
            {
                m_WiringOperator.JoinStreamEvent += handler;
                m_WiringOperator.Create(EndPoint);
                m_WiringOperator.JoinStreamEvent -= handler;
            }

            return(rudpSocket);
        }
Exemplo n.º 2
0
 public Socket(Line line, PeerConnecter connecter) : this(line)
 {
     _Status              = PeerStatus.Connecting;
     connecter.DoneEvent += ToTransmission;
     _Machine.Push(connecter);
 }
Exemplo n.º 3
0
 public Socket(Line Line, PeerConnecter Connecter) : this(Line)
 {
     m_Status             = PeerStatus.Connecting;
     Connecter.DoneEvent += ToTransmission;
     m_Machine.Push(Connecter);
 }