public NodesGroup( Network network, NodeConnectionParameters connectionParameters = null, NodeRequirement requirements = null) { AllowSameGroup = false; MaximumNodeConnection = 8; _Network = network; cs = new object(); _ConnectedNodes = new NodesCollection(); _ConnectionParameters = connectionParameters ?? new NodeConnectionParameters(); _ConnectionParameters = _ConnectionParameters.Clone(); _Requirements = requirements ?? new NodeRequirement(); _Disconnect = new CancellationTokenSource(); }
public NodeServer(Network network, ProtocolVersion version = ProtocolVersion.PROTOCOL_VERSION, int internalPort = -1) { AllowLocalPeers = true; InboundNodeConnectionParameters = new NodeConnectionParameters(); internalPort = internalPort == -1 ? network.DefaultPort : internalPort; _LocalEndpoint = new IPEndPoint(IPAddress.Parse("0.0.0.0").MapToIPv6Ex(), internalPort); _Network = network; _ExternalEndpoint = new IPEndPoint(_LocalEndpoint.Address, Network.DefaultPort); _Version = version; var listener = new EventLoopMessageListener <IncomingMessage>(ProcessMessage); _MessageProducer.AddMessageListener(listener); OwnResource(listener); _ConnectedNodes = new NodesCollection(); _ConnectedNodes.Added += _Nodes_NodeAdded; _ConnectedNodes.Removed += _Nodes_NodeRemoved; _ConnectedNodes.MessageProducer.AddMessageListener(listener); _Trace = new TraceCorrelation(NodeServerTrace.Trace, "Node server listening on " + LocalEndpoint); }