예제 #1
0
        public Node(string id, TransportLayer transportLayer = null)
        {
            Id = id.Trim().ToUpper();

            thread = new Thread(PacketProcessor);
            thread.IsBackground = true;
            thread.Start();

            transport = transportLayer ?? TransportLayer.GetTransport();
            transport.RegisterNode(this);
        }
예제 #2
0
        public void Dispose()
        {
            if (disposed)
            {
                return;
            }
            lock (this)
            {
                if (disposed)
                {
                    return;
                }

                transport.UnregisterNode(this);
                transport = null;

                thread.Abort();
                thread.Join(1000);

                disposed = true;
            }
        }
예제 #3
0
 static void Main(string[] args)
 {
     var transportLayer = TransportLayer.GetTransport();
     var node1          = new Node("N1", transportLayer);
     var node2          = new Node("N2", transportLayer);
 }
예제 #4
0
 public static TransportLayer GetTransport()
 {
     return(_transport ?? (_transport = new TransportLayer()));
 }