public void KeyGenerationProtocol_PublishKey(
            IOutputChannel output_channel)
        {
            // proof of knowledge [CaS97] for the public key

            // commitment
            BigInteger v = mpz_srandom.mpz_srandomm(q);
            BigInteger t = g.ModPow(v, p);
            // challenge
            // Here we use the well-known "Fiat-Shamir heuristic" to make
            // the PK non-interactive, i.e. we turn it into a statistically
            // zero-knowledge (Schnorr signature scheme style) proof of
            // knowledge (SPK) in the random oracle model.
            BigInteger c = mpz_shash_tools.mpz_shash(new BigInteger [] { g, h_i, t });

            // response
            BigInteger r = c * x_i;

            r  = r.FlipSign();
            r += v;
            r  = r % q;

            output_channel.Send(h_i);
            output_channel.Send(c);
            output_channel.Send(r);
            System.Diagnostics.Debug.WriteLine("g " + g.BitLength() + " h_i " + h_i.BitLength() + " t " + t.BitLength());
        }
Beispiel #2
0
 /// <summary>
 /// It is used by the client side to keep the BrokerClient alive.
 /// </summary>
 public void KeepConnectionAlive(IOutputChannel channel)
 {
     lock (this.syncObj)
     {
         this.channel = channel;
     }
 }
Beispiel #3
0
 public EventHandlersRepository(IOutputChannel outputChannel, IHostAddress clientHostAddress,
                                EloquentClient eloquentClient)
 {
     _outputChannel     = outputChannel;
     _clientHostAddress = clientHostAddress;
     _eloquentClient    = eloquentClient;
 }
Beispiel #4
0
        static void SendMessages(IOutputChannel clientChannel, Binding binding)
        {
            // Send messages to queue:
            Console.WriteLine("Started sending messages...");
            Random rand = new Random();

            for (int i = 0; i < SampleManager.NumMessages; ++i)
            {
                string sessionName = rand.Next(SampleManager.NumSessions).ToString();

                // Creating BrokeredMessageProperty
                BrokeredMessageProperty property = new BrokeredMessageProperty();
                property.SessionId = sessionName;
                string soapBody = "Order_" + Guid.NewGuid().ToString().Substring(0, 5);
                property.Label = soapBody;

                // Creating message and adding BrokeredMessageProperty to the properties bag
                Message message = Message.CreateMessage(binding.MessageVersion, "SoapAction", soapBody);
                message.Properties.Add(BrokeredMessageProperty.Name, property);

                // Sending message
                clientChannel.Send(message);
                SampleManager.OutputMessageInfo("Send", message);
                Thread.Sleep(senderDelay);
            }

            Console.WriteLine("Finished sending messages");
        }
 public LayeredDuplexChannel(ChannelManagerBase channelManager, IInputChannel innerInputChannel, EndpointAddress localAddress, IOutputChannel innerOutputChannel) : base(channelManager, innerInputChannel)
 {
     this.localAddress = localAddress;
     this.innerOutputChannel = innerOutputChannel;
     this.onInnerOutputChannelFaulted = new EventHandler(this.OnInnerOutputChannelFaulted);
     this.innerOutputChannel.Faulted += this.onInnerOutputChannelFaulted;
 }
        void CP_Prove(
            BigInteger x,
            BigInteger y,
            BigInteger gg,
            BigInteger hh,
            BigInteger alpha,
            IOutputChannel output_channel,
            bool fpowm_usage)
        {
            BigInteger b;
            BigInteger c;
            BigInteger r;
            BigInteger omega = mpz_srandom.mpz_srandomm(q);
            // proof of knowledge (equality of discrete logarithms) [CaS97]

            BigInteger a = g.ModPow(omega, p);

            b = g.ModPow(omega, p);

            // challenge
            // Here we use the well-known "Fiat-Shamir heuristic" to make
            // the PK non-interactive, i.e. we turn it into a statistically
            // zero-knowledge (Schnorr signature scheme style) proof of
            // knowledge (SPK) in the random oracle model.
            c = mpz_shash_tools.mpz_shash(new BigInteger [] { a, b, x, y, gg, hh });

            // response
            r = c * a;
            r = r.FlipSign();
            r = r + omega;
            r = r % q;
            output_channel.Send(c);
            output_channel.Send(r);
        }
 public static void SendOneWay(this IOutputChannel outputChannel, OneWayMessage message)
 {
     using (var context = outputChannel.BeginReadWrite())
     {
         context.Write(message.ToFrame());
     }
 }
        public static void SendWithAck(this IOutputChannel outputChannel, AcknowledgedMessage message)
        {
            IFrame response;

            try
            {
                using (var context = outputChannel.BeginReadWrite())
                {
                    context.Write(message.ToFrame());
                    response = context.Read();
                }
            }
            catch (Exception e)
            {
                throw new IOException("Connection failed. Check that server is still alive", e);
            }

            var responseMessage = Message.Create(response);

            switch (responseMessage)
            {
            case ErrorMessage errorMessage:
                throw errorMessage.ToException();

            case ExceptionMessage exceptionMessage:
                throw exceptionMessage.Exception;

            case AckMessage _:
                return;

            default:
                throw new IOException($"Unexpected message type: {responseMessage.MessageType}");
            }
        }
Beispiel #9
0
        private void SendMessage(IOutputChannel channel, string action, bool commit)
        {
            using (TransactionScope ts = new TransactionScope(TransactionScopeOption.RequiresNew))
            {
                Message message = Message.CreateMessage(MessageVersion.Default, action);

                if (this.Parameters.AsyncSend)
                {
                    IAsyncResult result = channel.BeginSend(message, null, null);
                    channel.EndSend(result);
                }
                else
                {
                    channel.Send(message);
                }

                if (commit)
                {
                    ts.Complete();
                }
                else
                {
                    Transaction.Current.Rollback();
                }
            }
        }
Beispiel #10
0
 public LayeredDuplexChannel(ChannelManagerBase channelManager, IInputChannel innerInputChannel, EndpointAddress localAddress, IOutputChannel innerOutputChannel) : base(channelManager, innerInputChannel)
 {
     this.localAddress                = localAddress;
     this.innerOutputChannel          = innerOutputChannel;
     this.onInnerOutputChannelFaulted = new EventHandler(this.OnInnerOutputChannelFaulted);
     this.innerOutputChannel.Faulted += this.onInnerOutputChannelFaulted;
 }
Beispiel #11
0
 /// <summary>
 /// Remove the IOutputChannel from the timer callback routine.
 /// </summary>
 public void RemoveChannel()
 {
     lock (this.syncObj)
     {
         this.channel = null;
     }
 }
 public TwoWayRemoteCallInterceptor(IOutputChannel channel, IMessageDispatcher messageDispatcher, IMessageFactory messageFactory, string interfaceName, RemoteExecutionPolicies policies)
 {
     _interfaceName     = interfaceName;
     _channel           = channel;
     _durableConnection = _channel as IDurableConnection;
     _messageDispatcher = messageDispatcher;
     _policies          = policies;
     _messageFactory    = messageFactory;
     GenerateNewCancellationToken();
     if (_durableConnection != null)
     {
         _durableConnection.ConnectionAborted += () =>
         {
             _tokenSource.Aborted = true;
             _tokenSource.Cancel();
         };
         _durableConnection.ConnectionRestored += () =>
         {
             _tokenSource.Restored = true;
             _tokenSource.Cancel();
             GenerateNewCancellationToken();
         };
         _durableConnection.ConnectionInterrupted += () =>
         {
             _tokenSource.Cancel();
             GenerateNewCancellationToken();
         };
     }
 }
        public RelayedOnewayHttpSender(BindingContext context, Uri uri, bool transportProtectionEnabled)
        {
            Binding wSHttpBinding;

            this.tokenProvider = TokenProviderUtility.CreateTokenProvider(context);
            if (this.tokenProvider != null)
            {
                transportProtectionEnabled = true;
            }
            if (!transportProtectionEnabled)
            {
                wSHttpBinding = new WSHttpBinding(SecurityMode.None);
                this.via      = RelayedHttpUtility.ConvertToHttpUri(uri);
            }
            else
            {
                wSHttpBinding = new WSHttpBinding(SecurityMode.Transport);
                this.via      = RelayedHttpUtility.ConvertToHttpsUri(uri);
            }
            this.channelFactory = new ChannelFactory <IOutputChannel>(wSHttpBinding);
            this.channelFactory.Open();
            this.channel = this.channelFactory.CreateChannel(new EndpointAddress(uri, new AddressHeader[0]), this.via);
            this.channel.Open();
            this.OnOnline(this, EventArgs.Empty);
        }
Beispiel #14
0
        internal virtual Message RequestCorrelated(Message msg, TimeSpan timeout, IOutputChannel channel)
        {
            DateTime startTime = DateTime.Now;

            OutputChannel.Send(msg, timeout);
            return(((IDuplexChannel)channel).Receive(timeout - (DateTime.Now - startTime)));
        }
Beispiel #15
0
 public void SetUp()
 {
     _repository        = new MockRepository();
     _messageDispatcher = _repository.DynamicMock <IMessageDispatcher>();
     _channel           = _repository.DynamicMock <IOutputChannel>();
     _responseHandler   = _repository.DynamicMock <IResponseHandler>();
 }
Beispiel #16
0
        IOutputChannel GetOutputChannel(Uri to, TimeoutHelper timeoutHelper)
        {
            IOutputChannel channel = this.innerChannelFactory.CreateChannel(new EndpointAddress(to));

            channel.Open(timeoutHelper.RemainingTime());
            return(channel);
        }
Beispiel #17
0
        private void SendMessages(TimeSpan channelTimeout, TimeSpan messageSendTimeout)
        {
            ChannelFactory <IOutputChannel> channelFactory =
                new ChannelFactory <IOutputChannel>(Util.GetBinding(), Queue);
            IOutputChannel proxy = channelFactory.CreateChannel();

            IAsyncResult[] resultArray = new IAsyncResult[MessageCount];

            for (int i = 0; i < MessageCount; i++)
            {
                Message toSend = Message.CreateMessage(MessageVersion.Default, string.Empty, i);
                resultArray[i] = proxy.BeginSend(toSend, messageSendTimeout, null, null);
            }

            for (int j = 0; j < MessageCount; j++)
            {
                proxy.EndSend(resultArray[j]);
            }

            IAsyncResult iocCloseResult = proxy.BeginClose(channelTimeout, null, null);

            Thread.Sleep(TimeSpan.FromMilliseconds(50.0)); // Dummy work
            proxy.EndClose(iocCloseResult);

            IAsyncResult chanFactCloseResult = channelFactory.BeginClose(channelTimeout, null, null);

            Thread.Sleep(TimeSpan.FromMilliseconds(50.0)); // Dummy work
            channelFactory.EndClose(chanFactCloseResult);
        }
Beispiel #18
0
                public SendAsyncResult(ServerCompositeDuplexChannel outer, Message message, TimeSpan timeout, AsyncCallback callback, object state)
                    : base(callback, state)
                {
                    this.timeoutHelper = new TimeoutHelper(timeout);
                    this.outputChannel = outer.ValidateStateAndGetOutputChannel(message, timeoutHelper);

                    bool success = false;

                    try
                    {
                        IAsyncResult result = outputChannel.BeginSend(message, timeoutHelper.RemainingTime(), sendCompleteCallback, this);
                        if (result.CompletedSynchronously)
                        {
                            CompleteSend(result);
                            this.Complete(true);
                        }
                        success = true;
                    }
                    finally
                    {
                        if (!success)
                        {
                            this.outputChannel.Abort();
                        }
                    }
                }
Beispiel #19
0
 //入口方法
 static void Main(string[] args)
 {
     try
     {
         //建立自定义的通道栈
         BindingElement[] bindingElements = new BindingElement[3];
         bindingElements[0] = new TextMessageEncodingBindingElement();
         //OneWayBindingElement可以使得传输通道支持数据报模式
         bindingElements[1] = new OneWayBindingElement();
         bindingElements[2] = new HttpTransportBindingElement();
         CustomBinding binding = new CustomBinding(bindingElements);
         using (Message message = Message.CreateMessage(binding.MessageVersion, "sendMessage", "Message Body"))
         {
             //创建ChannelFactory
             IChannelFactory <IOutputChannel> factory = binding.BuildChannelFactory <IOutputChannel>(new BindingParameterCollection());
             factory.Open();
             //这里创建IOutputChannel
             IOutputChannel outputChannel = factory.CreateChannel(new EndpointAddress("http://localhost/InputService"));
             outputChannel.Open();
             //发送消息
             outputChannel.Send(message);
             Console.WriteLine("已经成功发送消息!");
             outputChannel.Close();
             factory.Close();
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.ToString());
     }
     finally
     {
         Console.Read();
     }
 }
Beispiel #20
0
 internal OutputChannelBinder(IOutputChannel channel)
 {
     if (channel == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("channel");
     }
     this.channel = channel;
 }
 void PublishGroup(
     IOutputChannel output_channel)
 {
     output_channel.Send(p);
     output_channel.Send(q);
     output_channel.Send(g);
     output_channel.Send(k);
 }
 internal OutputChannelBinder(IOutputChannel channel)
 {
     if (channel == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("channel");
     }
     this.channel = channel;
 }
Beispiel #23
0
 public bool Verify_interactive(
     BigInteger c,
     List <BigInteger> m,
     IInputChannel input_channel,
     IOutputChannel output_channel)
 {
     return(Verify_interactive(c, m, input_channel, output_channel, true));
 }
Beispiel #24
0
        public Publisher(IOutputChannel outputChannel, MessageVersion messageVersion, IKnownContractCollector contractCollector, string busId)
        {
            _outputChannel     = outputChannel;
            _messageVersion    = messageVersion;
            _busId             = busId;
            _contractCollector = contractCollector;

            _outputChannel.Open();
        }
Beispiel #25
0
 internal OutputChannelBinder(IOutputChannel channel)
 {
     if (channel == null)
     {
         Fx.Assert("OutputChannelBinder.OutputChannelBinder: (channel != null)");
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("channel");
     }
     _channel = channel;
 }
Beispiel #26
0
 internal ChunkingWriter(Message originalMessage,TimeoutHelper chunkingTimeout, IOutputChannel outputChannel) : base()
 {
     this.version = originalMessage.Version;
     this.originalMessage = originalMessage;
     this.chunkingTimeout = chunkingTimeout;
     this.outputChannel = outputChannel;
     this.startState = new StartChunkState();
     chunkNum = 1;
 }
Beispiel #27
0
 internal ChunkingWriter(Message originalMessage, TimeoutHelper chunkingTimeout, IOutputChannel outputChannel) : base()
 {
     this.version         = originalMessage.Version;
     this.originalMessage = originalMessage;
     this.chunkingTimeout = chunkingTimeout;
     this.outputChannel   = outputChannel;
     this.startState      = new StartChunkState();
     chunkNum             = 1;
 }
Beispiel #28
0
 internal OutputChannelBinder(IOutputChannel channel)
 {
     if (channel == null)
     {
         Fx.Assert("OutputChannelBinder.OutputChannelBinder: (channel != null)");
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("channel");
     }
     _channel = channel;
 }
Beispiel #29
0
        public Subscription(string objectId, string eventName, IHostAddress clientHostAddress,
                            IOutputChannel outputChannel, IEvent @event)
        {
            _outputChannel    = outputChannel;
            _event            = @event;
            ObjectId          = objectId;
            ClientHostAddress = clientHostAddress;

            _event.Add(this);
        }
 /// <summary>
 /// Creates a new instance.
 /// </summary>
 /// <param name="projectSearchProvider">Search provider</param>
 /// <param name="projectBuilder">Project builder</param>
 /// <param name="outputChannel">Output channel</param>
 /// <param name="logger">Logger</param>
 public ProjectAggregator(IProjectSearchProvider projectSearchProvider
                          , IProjectBuilder projectBuilder
                          , IOutputChannel outputChannel
                          , ILogger logger)
 {
     _projectSearchProvider = projectSearchProvider;
     _projectBuilder        = projectBuilder;
     _outputChannel         = outputChannel;
     _logger = logger;
 }
Beispiel #31
0
        internal virtual Message RequestCorrelated(Message msg, TimeSpan timeout, IOutputChannel channel)
        {
            // FIXME: implement ConcurrencyMode check:
            // if it is .Single && this instance for a callback channel && the operation is invoked inside service operation, then error.

            DateTime startTime = DateTime.Now;

            OutputChannel.Send(msg, timeout);
            return(((IDuplexChannel)channel).Receive(timeout - (DateTime.Now - startTime)));
        }
 /// <summary>
 ///     Creates a new instance of the Statsd client.
 /// </summary>
 /// <param name="host">The statsd or statsd.net server.</param>
 /// <param name="port"></param>
 /// <param name="prefix">A string prefix to prepend to every metric.</param>
 /// <param name="rethrowOnError">If True, rethrows any exceptions caught due to bad configuration.</param>
 /// <param name="outputChannel">Optional output channel (useful for mocking / testing).</param>
 public Statsd(string host, int port, string prefix = null, bool rethrowOnError = false, IOutputChannel outputChannel = null)
 {
     if (outputChannel == null)
     {
         InitialiseInternal(() => new UdpOutputChannel(host, port), prefix, rethrowOnError);
     }
     else
     {
         InitialiseInternal(() => outputChannel, prefix, rethrowOnError);
     }
 }
 public DurableInstanceContextOutputChannel(
     ChannelManagerBase channelManager,
     ContextType contextType,
     IOutputChannel innerChannel,
     string contextStoreLocation)
     : base(channelManager, innerChannel)
 {
     this.contextType = contextType;
     this.innerOutputChannel = innerChannel;
     this.contextStoreLocation = contextStoreLocation;
     this.endpointAddress = innerChannel.RemoteAddress;
 }
Beispiel #34
0
        /// <summary>
        /// Creates an EloquentObjects client with ability to specify custom settings and dependencies.
        /// </summary>
        /// <param name="serverAddress">Address of the server that hosts object. Can be prefixed with 'tcp://' for TCP binding or 'pipe://' for Named Pipes binding</param>
        /// <param name="clientAddress">Client-side address that is used to send server-to-client events. Can be prefixed with 'tcp://' for TCP binding or 'pipe://' for Named Pipes binding</param>
        /// <param name="settings">Custom settings</param>
        /// <param name="serializerFactory">Factory that can create serializer to be used for serializing/deserializing data sent between server and client</param>
        /// <exception cref="ArgumentException">Client Uri scheme should match server Uri scheme</exception>
        public EloquentClient(string serverAddress, string clientAddress, EloquentSettings settings, [CanBeNull] ISerializerFactory serializerFactory = null)
        {
            _serializerFactory = serializerFactory ?? new DefaultSerializerFactory();

            var serverUri = new Uri(serverAddress);
            var clientUri = new Uri(clientAddress);

            var serverScheme = serverUri.GetComponents(UriComponents.Scheme, UriFormat.Unescaped);
            var clientScheme = clientUri.GetComponents(UriComponents.Scheme, UriFormat.Unescaped);

            if (serverScheme != clientScheme)
            {
                throw new ArgumentException("Client Uri scheme should match server Uri scheme");
            }

            var binding = new BindingFactory().Create(serverScheme, settings);

            var serverHostAddress = HostAddress.CreateFromUri(serverUri);

            _clientHostAddress = HostAddress.CreateFromUri(clientUri);

            _contractDescriptionFactory = new CachedContractDescriptionFactory(new ContractDescriptionFactory());

            _proxyGenerator = new ProxyGenerator();

            try
            {
                _inputChannel = binding.CreateInputChannel(_clientHostAddress);
            }
            catch (Exception e)
            {
                throw new IOException("Failed creating input channel", e);
            }

            try
            {
                _outputChannel = binding.CreateOutputChannel(serverHostAddress);
            }
            catch (Exception e)
            {
                throw new IOException("Connection failed. Server not found.", e);
            }

            _inputChannel.Start();

            //Send HelloMessage to create a session
            var helloMessage = new HelloMessage(_clientHostAddress);

            _outputChannel.SendWithAck(helloMessage);

            _eventHandlersRepository = new EventHandlersRepository(_outputChannel, _clientHostAddress, this);
            _sessionAgent            = new SessionAgent(binding, _inputChannel, _outputChannel, _clientHostAddress, _eventHandlersRepository);
        }
Beispiel #35
0
 public DurableInstanceContextOutputChannel(
     ChannelManagerBase channelManager,
     ContextType contextType,
     IOutputChannel innerChannel,
     string contextStoreLocation)
     : base(channelManager, innerChannel)
 {
     this.contextType          = contextType;
     this.innerOutputChannel   = innerChannel;
     this.contextStoreLocation = contextStoreLocation;
     this.endpointAddress      = innerChannel.RemoteAddress;
 }
        public SendAsyncResult(IOutputChannel innerChannel, Message message, TimeSpan timeout, AsyncCallback onSendDone, AsyncCallback callback, object state, DependencyTelemetry telemetry)
            : base(onSendDone, callback, state, telemetry)
        {
            this.InnerChannel = innerChannel;
            this.RequestId    = message.Headers.MessageId;

            this.OriginalResult = innerChannel.BeginSend(message, timeout, OnComplete, this);
            if (this.OriginalResult.CompletedSynchronously)
            {
                innerChannel.EndSend(this.OriginalResult);
                this.Complete(true);
            }
        }
		public SecurityOutputChannel (IOutputChannel innerChannel, SecurityChannelFactory<IOutputChannel> source)
			: base (innerChannel)
		{
			this.source = source;
			InitializeSecurityFunctionality (source.SecuritySupport);
		}
Beispiel #38
0
        public void Run()
        {
            IRawBodyUtility bodyUtil = new RawEncoderUtility();

            IInputChannel startQueue = null;
            IOutputChannel doneQueue = null;
            UInt64 batchSize = (UInt64)opts.pubTxSize;
            bool txPending = false;
            AmqpProperties amqpProperties = null;

            if (opts.durable)
            {
                amqpProperties = new AmqpProperties();
                amqpProperties.Durable = true;
            }

            try
            {
                publishQueue = QueueChannelFactory.CreateWriterChannel(this.destination, this.routingKey);
                doneQueue = QueueChannelFactory.CreateWriterChannel("", this.Fqn("pub_done"));
                startQueue = QueueChannelFactory.CreateReaderChannel(this.Fqn("pub_start"));

                // wait for our start signal
                Message msg;
                msg = startQueue.Receive(TimeSpan.MaxValue);
                Expect(bodyUtil.GetText(msg), "start");
                msg.Close();

                Stopwatch stopwatch = new Stopwatch();
                AsyncCallback sendCallback = new AsyncCallback(this.AsyncSendCB);

                byte[] data = new byte[this.msgSize];
                IAsyncResult sendResult = null;

                Console.WriteLine("sending {0}", this.msgCount);
                stopwatch.Start();

                if (batchSize > 0)
                {
                    Transaction.Current = new CommittableTransaction();
                }

                for (UInt64 i = 0; i < this.msgCount; i++)
                {
                    StampSequenceNo(data, i);
                    msg = bodyUtil.CreateMessage(data);
                    if (amqpProperties != null)
                    {
                        msg.Properties.Add("AmqpProperties", amqpProperties);
                    }

                    sendResult = publishQueue.BeginSend(msg, TimeSpan.MaxValue, sendCallback, msg);

                    if (batchSize > 0)
                    {
                        txPending = true;
                        if (((i + 1) % batchSize) == 0)
                        {
                            ((CommittableTransaction)Transaction.Current).Commit();
                            txPending = false;
                            Transaction.Current = new CommittableTransaction();
                        }
                    }
                }

                if (txPending)
                {
                    ((CommittableTransaction)Transaction.Current).Commit();
                }

                Transaction.Current = null;

                sendResult.AsyncWaitHandle.WaitOne();
                stopwatch.Stop();

                double mps = (msgCount / stopwatch.Elapsed.TotalSeconds);

                msg = bodyUtil.CreateMessage(String.Format("{0:0.##}", mps));
                doneQueue.Send(msg, TimeSpan.MaxValue);
                msg.Close();
            }
            finally
            {
                Close((IChannel)doneQueue);
                Close((IChannel)publishQueue);
                Close(startQueue);
            }
        }
 public HtmlFileResultsWriter(IOutputChannel channel)
 {
     this.channel = channel;
 }
 public SimpleTextResultsWriter(IOutputChannel channel)
 {
     this.channel = channel;
 }
 public RabbitMQReplyToOutputChannel(Uri replyToExchange, IOutputChannel channel)
     : base(channel)
 {
     m_replyToExchange = replyToExchange;
 }
		protected SecurityOutputChannelBase (IOutputChannel innerChannel)
			: base (innerChannel)
		{
			Opened += new EventHandler (AcquireSecurityKey);
			Closing += new EventHandler (ReleaseSecurityKey);
		}
		internal override Message RequestCorrelated (Message msg, TimeSpan timeout, IOutputChannel channel)
		{
			DateTime startTime = DateTime.Now;
			Message ret = null;
			ManualResetEvent wait = new ManualResetEvent (false);
			Action<Message> handler = delegate (Message reply) {
				ret = reply;
				wait.Set ();
			};
			ReplyHandlerQueue.Enqueue (handler);
			channel.Send (msg, timeout);
			if (ret == null && !wait.WaitOne (timeout - (DateTime.Now - startTime)))
				throw new TimeoutException ();
			return ret;
		}
 private void InitialiseInternal(Func<IOutputChannel> createOutputChannel, string prefix, bool rethrowOnError)
 {
     _prefix = prefix;
     if (_prefix != null && _prefix.EndsWith("."))
     {
         _prefix = _prefix.Substring(0, _prefix.Length - 1);
     }
     try
     {
         _outputChannel = createOutputChannel();
     }
     catch (Exception ex)
     {
         if (rethrowOnError)
         {
             throw;
         }
         Trace.TraceError("Could not initialise the Statsd client: {0} - falling back to NullOutputChannel.", ex.Message);
         _outputChannel = new NullOutputChannel();
     }
 }