/// <summary> /// 构造器 /// </summary> /// <param name="group">组播地址和端口</param> public Pacemaker(IPEndPoint group = null) { var scope = new DynamicScope(); scope.Setup(new Networks()); scope.Setup(_sockets = new MulticastSockets(group ?? Default.Group)); scope.Setup(_monitor); scope.Setup(_broadcaster); _monitor.OpenAll(); }
/// <summary> /// 构造器 /// </summary> /// <param name="group">组播地址和端口</param> public Probe(IPEndPoint group = null) { var scope = new DynamicScope(); scope.Setup(_group); scope.Setup(_addresses); scope.Setup(new GroupMonitor()); scope.Setup(new PortMonitor()); scope.Setup(new Networks()); scope.Setup(_sockets = new MulticastSockets(group ?? Default.Group)); scope.Setup(_monitor); scope.Setup(_receiver); _monitor.BindAll(); }
/// <summary> /// 构造器 /// </summary> /// <remarks> /// 远程节点启动时会绑定所有网络接口以进行接收 /// </remarks> /// <param name="name">节点名字</param> /// <param name="size">组播分片长度</param> /// <param name="group">组播地址</param> /// <param name="newMemberDetected">发现新成员上线时的回调</param> /// <param name="additions">自定义组件</param> public RemoteHub(string name = null, uint size = 0x4000, IPEndPoint group = null, Action <string> newMemberDetected = null, params IComponent[] additions ) { _groupMonitor = new GroupMonitor(detected: newMemberDetected); _broadcaster = new MulticastBroadcaster(size); _scope = new DynamicScope(); _scope.Setup(new Name(name ?? $"RemoteHub[{Guid.NewGuid()}]")); _scope.Setup(_group); _scope.Setup(_groupMonitor); _scope.Setup(_networks); _scope.Setup(new MulticastSockets(group ?? Default.Group)); _scope.Setup(Monitor); _scope.Setup(_broadcaster); _scope.Setup(_receiver); _scope.Setup(_slicer); _scope.Setup(_addresses); _scope.Setup(_servers); _scope.Setup(_synchronizer1); _scope.Setup(_synchronizer2); _scope.Setup(_client); _scope.Setup(_server); Monitor.BindAll(); foreach (var dependency in additions) { _scope.Setup(dependency); } }