public IpcServiceBus(string publisherAddress, string subscriberAddress, bool verboseLog, ITraceWriter traceWriter) { if (traceWriter == null) { throw new ArgumentNullException("traceWriter"); } _traces = traceWriter; _verboseLog = verboseLog; _publisherAddress = publisherAddress; _subscriberAddress = subscriberAddress; _context = NetMQContext.Create(); _synchronizer = new SocketSynchronizer(_context, _publisherAddress, _subscriberAddress, TimeSpan.FromMilliseconds(500), _verboseLog, _traces); }
/// <summary> /// <para>Blocks until the proxy is operational.</para> /// </summary> /// <returns>true en cas de succès.</returns> private bool TrySync(TimeSpan timeout) { string pubAddress = _xSubscriberAddress.StartsWith("tcp://*") ? _xSubscriberAddress.Replace("*", "localhost") : _xSubscriberAddress; string subAddress = _xPublisherAddress.StartsWith("tcp://*") ? _xPublisherAddress.Replace("*", "localhost") : _xPublisherAddress; var publisher = new Publisher(pubAddress, _context, _verboseLog, _traces); try { var synchronizer = new SocketSynchronizer(_context, pubAddress, subAddress, timeout, _verboseLog, _traces); if (synchronizer.TrySync(publisher)) { return(!_isFaultedState); } } finally { publisher.Terminate(); } return(false); }