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); }
public void Dispose() { if (disposed) { return; } lock (this) { if (disposed) { return; } transport.UnregisterNode(this); transport = null; thread.Abort(); thread.Join(1000); disposed = true; } }
static void Main(string[] args) { var transportLayer = TransportLayer.GetTransport(); var node1 = new Node("N1", transportLayer); var node2 = new Node("N2", transportLayer); }
public static TransportLayer GetTransport() { return(_transport ?? (_transport = new TransportLayer())); }