protected virtual void HandleChanged(IInputChannel sender, object newValue) { if (newValue is double) { this.rule.Value = (double)newValue; } }
private static Task<Message> ReceiveAsync(IInputChannel channel) { return Task.Factory.FromAsync( (c, s) => ((IInputChannel)s).BeginReceive(c, s), r => ((IInputChannel)r.AsyncState).EndReceive(r), channel); }
bool VerifiableDecryptionProtocol_Verify_Update( BigInteger c_1, IInputChannel input_channel) { BigInteger d_j = input_channel.Recieve(); BigInteger h_j_fp = input_channel.Recieve(); // public key stored? String str = h_j_fp.ToString(); if (!h_j.ContainsKey(str)) { return(false); } // verify the in-group property if (!CheckElement(d_j)) { return(false); } // invoke CP(d_j, h_j, c_1, g; x_j) as verifier if (!CP_Verify(d_j, h_j[str], c_1, g, input_channel, false)) { return(false); } // update the value of $d$ d = d * d_j; d = d * p; // finish return(true); }
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; }
private TObjectType ReceiveMessage <TObjectType>() { Uri endpoint = new Uri("amqp:message_queue"); IChannelListener <IInputChannel> listener = Util.GetBinding().BuildChannelListener <IInputChannel>(endpoint, new BindingParameterCollection()); listener.Open(); IInputChannel service = listener.AcceptChannel(TimeSpan.FromSeconds(10)); service.Open(); Message receivedMessage = service.Receive(TimeSpan.FromSeconds(10)); Assert.NotNull(receivedMessage, "Message was not received"); try { TObjectType receivedObject = receivedMessage.GetBody <TObjectType>(); return(receivedObject); } catch (SerializationException) { Assert.Fail("Deserialized object not of correct type"); } finally { receivedMessage.Close(); service.Close(); listener.Close(); } return(default(TObjectType)); }
private void ReceiveNonTryMessages(TimeSpan channelTimeout, TimeSpan messageTimeout) { IChannelListener inputChannelParentListener; IInputChannel inputChannel = this.RetrieveAsyncChannel(this.endpoint, channelTimeout, out inputChannelParentListener); inputChannel.Open(); IAsyncResult[] resultArray = new IAsyncResult[MessageCount]; try { for (int i = 0; i < MessageCount; i++) { resultArray[i] = inputChannel.BeginReceive(messageTimeout, null, null); } for (int j = 0; j < MessageCount; j++) { inputChannel.EndReceive(resultArray[j]); } } finally { IAsyncResult channelCloseResult = inputChannel.BeginClose(channelTimeout, null, null); Thread.Sleep(TimeSpan.FromMilliseconds(50.0)); // Dummy work inputChannel.EndClose(channelCloseResult); // Asynchronous listener close has not been implemented. ////IAsyncResult listenerCloseResult = inputChannelParentListener.BeginClose(channelTimeout, null, null); ////Thread.Sleep(TimeSpan.FromMilliseconds(50.0)); // Dummy work ////inputChannelParentListener.EndClose(listenerCloseResult); inputChannelParentListener.Close(); } }
private void ReceiveTryMessages(TimeSpan channelAcceptTimeout, TimeSpan messageReceiveTimeout) { IChannelListener <IInputChannel> listener = Util.GetBinding().BuildChannelListener <IInputChannel>(this.endpoint, new BindingParameterCollection()); listener.Open(); IInputChannel inputChannel = listener.AcceptChannel(channelAcceptTimeout); IAsyncResult channelResult = inputChannel.BeginOpen(channelAcceptTimeout, null, null); Thread.Sleep(TimeSpan.FromMilliseconds(50.0)); inputChannel.EndOpen(channelResult); IAsyncResult[] resultArray = new IAsyncResult[MessageCount]; for (int i = 0; i < MessageCount; i++) { resultArray[i] = inputChannel.BeginTryReceive(messageReceiveTimeout, null, null); } for (int j = 0; j < MessageCount; j++) { Message tempMessage; Assert.True(inputChannel.EndTryReceive(resultArray[j], out tempMessage), "Did not successfully receive message #{0}", j); } inputChannel.Close(); listener.Close(); }
static void Main(string[] args) { try { //建立和发送端相同的通道栈 BindingElement[] bindingElements = new BindingElement[3]; bindingElements[0] = new TextMessageEncodingBindingElement();//文本编码 //oneWayBindingElement() 传输通道支持数据报模式 bindingElements[1] = new OneWayBindingElement(); bindingElements[2] = new NamedPipeTransportBindingElement();//命名管道 CustomBinding binding = new CustomBinding(bindingElements); //建立ChannelListner倾听者,接收数据 IChannelListener <IInputChannel> listener = binding.BuildChannelListener <IInputChannel>(new Uri("net.pipe://localhost/InputService"), new BindingParameterCollection()); listener.Open();//打开ChannelListner IInputChannel inputChannel = listener.AcceptChannel(); //创建IInputChannel inputChannel.Open(); //打开IInputChannel Console.WriteLine("开始接受消息.."); Message message = inputChannel.Receive(); //接受并打印 Console.WriteLine($"接收一条消息,action为{message.Headers.Action},Body为{message.GetBody<string>()}"); message.Close(); //关闭消息 inputChannel.Close(); //关闭通道 listener.Close(); //关闭监听器 Console.Read(); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } finally { Console.Read(); } }
public PedersenCommitmentScheme( int n, IInputChannel chanal, long fieldsize, long subgroupsize) { F_size = fieldsize; G_size = subgroupsize; Debug.Assert(n >= 1); // Initialize the parameters of the commitment scheme. p = chanal.Recieve(); q = chanal.Recieve(); k = chanal.Recieve(); h = chanal.Recieve(); System.Diagnostics.Debug.WriteLine("PedersenCommitmentScheme::PedersenCommitmentScheme p " + p.BitLength()); System.Diagnostics.Debug.WriteLine("PedersenCommitmentScheme::PedersenCommitmentScheme q " + q.BitLength()); System.Diagnostics.Debug.WriteLine("PedersenCommitmentScheme::PedersenCommitmentScheme k " + k.BitLength()); System.Diagnostics.Debug.WriteLine("PedersenCommitmentScheme::PedersenCommitmentScheme h " + h.BitLength()); g = new List <BigInteger>(); for (int i = 0; i < n; i++) { g.Add(chanal.Recieve()); } }
public GrothSKC( int n, IInputChannel input_channel, long ell_e) : this(n, input_channel, ell_e, TMCG_DDH_SIZE, TMCG_DLSE_SIZE) { }
static void Main(string[] args) { try { //建立和发送端相同的通道栈 BindingElement[] bindingElements = new BindingElement[3]; bindingElements[0] = new TextMessageEncodingBindingElement(); bindingElements[1] = new OneWayBindingElement(); bindingElements[2] = new HttpTransportBindingElement(); CustomBinding binding = new CustomBinding(bindingElements); //建立ChannelListner IChannelListener <IInputChannel> listener = binding.BuildChannelListener <IInputChannel>(new Uri("http://localhost/InputService"), new BindingParameterCollection()); listener.Open(); //创建IInputChannel IInputChannel inputChannel = listener.AcceptChannel(); inputChannel.Open(); Console.WriteLine("开始接受消息。。。"); //接受并打印消息 Message message = inputChannel.Receive(); Console.WriteLine("接受到一条消息,action为:{0},body为:{1}", message.Headers.Action, message.GetBody <String>()); message.Close(); inputChannel.Close(); listener.Close(); Console.Read(); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } finally { Console.Read(); } }
public bool VerifiableMaskingProtocol_Verify( BigInteger m, BigInteger c_1, BigInteger c_2, IInputChannel input_channel) { // verify the in-group properties if (!CheckElement(c_1) || !CheckElement(c_2)) { return(false); } // invoke CP(c_1, c_2/m, g, h; r) as verifier if (ToolsMathBigInteger.AreCoprime(m, p)) { return(false); } BigInteger foo = m.ModInverse(p); foo = foo * c_2; foo = foo % p; if (!CP_Verify(c_1, foo, g, h, input_channel, true)) { return(false); } // finish return(true); }
private static Task <Message> ReceiveAsync(IInputChannel channel) { return(Task.Factory.FromAsync( (c, s) => ((IInputChannel)s).BeginReceive(c, s), r => ((IInputChannel)r.AsyncState).EndReceive(r), channel)); }
/// <summary> /// Creates an EloquentObjects server with ability to specify custom settings and dependencies. /// </summary> /// <param name="address">Address of the server that hosts object. 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> public EloquentServer(string address, EloquentSettings settings, [CanBeNull] ISerializerFactory serializerFactory = null) { _serializerFactory = serializerFactory ?? new DefaultSerializerFactory(); var uri = new Uri(address); var scheme = uri.GetComponents(UriComponents.Scheme, UriFormat.Unescaped); var binding = new BindingFactory().Create(scheme, settings); var serverHostAddress = HostAddress.CreateFromUri(uri); _contractDescriptionFactory = new CachedContractDescriptionFactory(new ContractDescriptionFactory()); try { _inputChannel = binding.CreateInputChannel(serverHostAddress); } catch (Exception e) { throw new IOException("Failed creating input channel", e); } _objectsRepository = new ObjectsRepository(); _server = new Server(binding, _inputChannel, _objectsRepository); }
private static Exception CreateReceiveTimedOutException(IInputChannel channel, TimeSpan timeout) { if (channel.LocalAddress != null) { return(new TimeoutException(System.ServiceModel.SR.GetString("ReceiveTimedOut", new object[] { channel.LocalAddress.Uri.AbsoluteUri, timeout }))); } return(new TimeoutException(System.ServiceModel.SR.GetString("ReceiveTimedOutNoLocalAddress", new object[] { timeout }))); }
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)); }
// Token: 0x06001567 RID: 5479 RVA: 0x0000E5C2 File Offset: 0x0000C7C2 public UserInputMap(string description, GameInputKey s, IInputChannel channel = null, bool isConfigurable = true, bool isEventSender = true, KeyCode prefix = KeyCode.None) { this._prefix = prefix; this.IsConfigurable = isConfigurable; this.IsEventSender = isEventSender; this.Channel = channel; this.Slot = s; this.Description = description; }
public DurableInstanceContextInputChannel( ChannelManagerBase channelManager, ContextType contextType, IInputChannel innerChannel) : base(channelManager, innerChannel) { this.contextType = contextType; this.innerInputChannel = innerChannel; }
internal InputChannelBinder(IInputChannel channel, Uri listenUri) { if (channel == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("channel"); } this.channel = channel; this.listenUri = listenUri; }
void ProcessInput(IInputChannel input, Message message) { try { ProcessInputCore(input, message); } catch (Exception ex) { // FIXME: log it. Console.WriteLine(ex); } }
private static void ReceiveMessages() { // Read messages from queue until queue is empty Console.WriteLine("Reading messages from queue {0}...", SampleManager.SessionlessQueueName); Console.WriteLine("Receiver Type: Receive and Delete"); // Create channel listener and channel using NetMessagingBinding NetMessagingBinding messagingBinding = new NetMessagingBinding("messagingBinding"); EndpointAddress address = SampleManager.GetEndpointAddress(SampleManager.SessionlessQueueName, serviceBusNamespace); TransportClientEndpointBehavior securityBehavior = new TransportClientEndpointBehavior(); securityBehavior.TokenProvider = TokenProvider.CreateSharedAccessSignatureTokenProvider(serviceBusKeyName, serviceBusKey); IChannelListener <IInputChannel> inputChannelListener = null; IInputChannel inputChannel = null; try { inputChannelListener = messagingBinding.BuildChannelListener <IInputChannel>(address.Uri, securityBehavior); inputChannelListener.Open(); inputChannel = inputChannelListener.AcceptChannel(); inputChannel.Open(); while (true) { try { // Receive message from queue. If no more messages available, the operation throws a TimeoutException. Message receivedMessage = inputChannel.Receive(receiveMessageTimeout); SampleManager.OutputMessageInfo("Receive", receivedMessage); // Since the message body contains a serialized string one can access it like this: //string soapBody = receivedMessage.GetBody<string>(); } catch (TimeoutException) { break; } } // Close inputChannel.Close(); inputChannelListener.Close(); } catch (Exception) { if (inputChannel != null) { inputChannel.Abort(); } if (inputChannelListener != null) { inputChannelListener.Abort(); } throw; } }
internal static Message HelpReceive(IInputChannel channel, TimeSpan timeout) { Message message; if (!channel.TryReceive(timeout, out message)) { throw Microsoft.ServiceBus.Diagnostics.DiagnosticUtility.ExceptionUtility.ThrowHelperError(Microsoft.ServiceBus.Channels.InputChannel.CreateReceiveTimedOutException(channel, timeout)); } return(message); }
internal void Init(IInputChannel channel, Uri listenUri) { if (!((channel != null))) { Fx.Assert("InputChannelBinder.InputChannelBinder: (channel != null)"); throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(channel)); } _channel = channel; ListenUri = listenUri; }
public IChannelBinder EndAccept(IAsyncResult result) { IInputChannel channel = this.listener.EndAcceptChannel(result); if (channel == null) { return(null); } return(new InputChannelBinder(channel, this.listener.Uri)); }
public IChannelBinder Accept(TimeSpan timeout) { IInputChannel channel = this.listener.AcceptChannel(timeout); if (channel == null) { return(null); } return(new InputChannelBinder(channel, this.listener.Uri)); }
internal InputChannelBinder(IInputChannel channel, Uri listenUri) { if (!((channel != null))) { Fx.Assert("InputChannelBinder.InputChannelBinder: (channel != null)"); throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("channel"); } this.channel = channel; this.listenUri = listenUri; }
internal override IInputChannel OnCreateInputChannel(SubscriberConfigurator configurator) { IInputChannel inputChannel = CreateInputChannel(configurator.BufferManager, configurator.QueueName); if (inputChannel == null) { throw new NoIncomingConnectionAcceptedException(); } return(inputChannel); }
public async Task <IChannelBinder> AcceptAsync(CancellationToken token) { IInputChannel channel = await listener.AcceptChannelAsync(token); if (channel == null) { return(null); } return(new InputChannelBinder(channel, listener.Uri)); }
private static Exception CreateReceiveTimedOutException(IInputChannel channel, TimeSpan timeout) { if (channel.LocalAddress != null) { return(new TimeoutException(SR.Format(SR.ReceiveTimedOut, channel.LocalAddress.Uri.AbsoluteUri, timeout))); } else { return(new TimeoutException(SR.Format(SR.ReceiveTimedOutNoLocalAddress, timeout))); } }
public ISubscription RegisterSubscription <T>(T instance, Action <ISubscriberConfigurator> configure = null) { var configurator = CreateConfigurator(configure); IInputChannel inputChannel = OnCreateInputChannel(configurator); IMessageFilter messageFilter = OnCreateMessageFilter(inputChannel); ISubscriptionDispatcher dispatcher = new SubscriptionDispatcher(configurator.ErrorSubscriber, BusId); return(new TypeSubscription(inputChannel, messageFilter, dispatcher, instance)); }
void worker(TimeSpan timeout, object state) { try { IInputChannel inputChannel = ChannelListener.AcceptChannel(timeout); Message message = inputChannel.Receive(); Runtime.PublishOneWay(new PublishRequest(typeof(IPassThroughServiceContract), message.Headers.Action, message)); } catch (TimeoutException) { } }
void ProcessInput (IInputChannel input, Message message) { try { if (!MessageMatchesEndpointDispatcher (message, Runtime.CallbackDispatchRuntime.EndpointDispatcher)) throw new EndpointNotFoundException (String.Format ("The request message has the target '{0}' with action '{1}' which is not reachable in this service contract", message.Headers.To, message.Headers.Action)); new InputOrReplyRequestProcessor (Runtime.CallbackDispatchRuntime, input).ProcessInput (message); } catch (Exception ex) { // FIXME: log it. Console.WriteLine (ex); } finally { // unless it is closed by session/call manager, move it back to the loop to receive the next message. if (loop && input.State != CommunicationState.Closed) ProcessRequestOrInput (input); } }
void ProcessRequestOrInput (IInputChannel input) { while (true) { if (!loop) return; if (receive_synchronously) { Message msg; if (input.TryReceive (receive_timeout, out msg)) ProcessInput (input, msg); } else { input.BeginTryReceive (receive_timeout, TryReceiveDone, input); loop_handle.WaitOne (receive_timeout); } } }
protected ReceiveMessageAndVerifySecurityAsyncResultBase(IInputChannel innerChannel, TimeSpan timeout, AsyncCallback callback, object state) : base(callback, state) { this.timeoutHelper = new TimeoutHelper(timeout); this.innerChannel = innerChannel; }
internal override IMessageFilter OnCreateMessageFilter(IInputChannel channel) { return new NullMessageFilter(); }
protected MessagePumpSubscriptionBase(IInputChannel inputChannel, IMessageFilter messageFilter, IDispatcher dispatcher) : base(inputChannel, messageFilter, dispatcher) { _receiver = new Thread(MessagePump); }
void ProcessInput (IInputChannel input, Message message) { try { ProcessInputCore (input, message); } catch (Exception ex) { // FIXME: log it. Console.WriteLine (ex); } }
void ProcessInputCore (IInputChannel input, Message message) { bool isReply = message != null && Contract.Operations.Any (od => (od.DeclaringContract.CallbackContractType == od.DeclaringContract.ContractType || !od.InCallbackContract) && od.Messages.Any (md => md.Action == message.Headers.Action)); if (isReply) { if (ReplyHandlerQueue.Count > 0) { if (isReply) { var h = ReplyHandlerQueue.Dequeue (); h (message); return; } } } if (message.IsFault) { Exception ex; var mf = MessageFault.CreateFault (message, 0x10000); if (FaultConverter.GetDefaultFaultConverter (message.Version).TryCreateException (message, mf, out ex)) // FIXME: get maxMessageSize somehow throw ex; else throw new FaultException (mf); } if (!MessageMatchesEndpointDispatcher (message, Runtime.CallbackDispatchRuntime.EndpointDispatcher)) throw new EndpointNotFoundException (String.Format ("The request message has the target '{0}' with action '{1}' which is not reachable in this service contract", message.Headers.To, message.Headers.Action)); new InputOrReplyRequestProcessor (Runtime.CallbackDispatchRuntime, input).ProcessInput (message); }
void ProcessInput (IInputChannel input, Message message) { try { ProcessInputCore (input, message); } catch (Exception ex) { // FIXME: log it. Console.WriteLine (ex); } finally { // unless it is closed by session/call manager, move it back to the loop to receive the next message. if (loop && input.State != CommunicationState.Closed) ProcessRequestOrInput (input); } }
public void Run() { IRawBodyUtility bodyUtil = new RawEncoderUtility(); IOutputChannel readyQueue = null; IOutputChannel doneQueue = null; UInt64 batchSize = (UInt64)opts.subTxSize; bool txPending = false; byte[] data = null; try { this.subscribeQueue = QueueChannelFactory.CreateReaderChannel(this.queue); readyQueue = QueueChannelFactory.CreateWriterChannel("", this.Fqn("sub_ready")); doneQueue = QueueChannelFactory.CreateWriterChannel("", this.Fqn("sub_done")); Message msg = bodyUtil.CreateMessage("ready"); readyQueue.Send(msg, TimeSpan.MaxValue); msg.Close(); Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); Console.WriteLine("receiving {0}", this.msgCount); UInt64 expect = 0; if (batchSize > 0) { Transaction.Current = new CommittableTransaction(); } for (UInt64 i = 0; i < this.msgCount; i++) { msg = subscribeQueue.Receive(TimeSpan.MaxValue); data = bodyUtil.GetBytes(msg, data); msg.Close(); if (data.Length != this.msgSize) { throw new Exception("subscribe message size mismatch"); } UInt64 n = GetSequenceNumber(data); if (n != expect) { throw new Exception(String.Format("message sequence error. expected {0} got {1}", expect, n)); } expect = n + 1; 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; stopwatch.Stop(); double mps = (msgCount / stopwatch.Elapsed.TotalSeconds); msg = bodyUtil.CreateMessage(String.Format("{0:0.##}", mps)); doneQueue.Send(msg, TimeSpan.MaxValue); msg.Close(); subscribeQueue.Close(); } finally { Close((IChannel)doneQueue); Close((IChannel)this.subscribeQueue); Close(readyQueue); } }
protected SubscriptionBase(IInputChannel inputChannel, IMessageFilter messageFilter, IDispatcher dispatcher) { _inputChannel = inputChannel; _messageFilter = messageFilter; _dispatcher = dispatcher; }
private Message ReceiveMessage(IInputChannel channel, bool commit) { Message message = null; using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required)) { bool messageDetected = false; if (this.Parameters.AsyncWaitForMessage) { IAsyncResult result = channel.BeginWaitForMessage(this.Parameters.WaitForMessageTimeout, null, null); messageDetected = channel.EndWaitForMessage(result); } else { messageDetected = channel.WaitForMessage(this.Parameters.WaitForMessageTimeout); } if (this.Parameters.WaitForMessage) { lock (this.Results) { this.Results.Add(String.Format("WaitForMessage returned {0}", messageDetected)); } } if (messageDetected) { if (this.Parameters.AsyncReceive) { if (this.Parameters.TryReceive) { IAsyncResult result = channel.BeginTryReceive(this.Parameters.ReceiveTimeout, null, null); bool ret = channel.EndTryReceive(result, out message); lock (this.Results) { this.Results.Add(String.Format("TryReceive returned {0}", ret)); } } else { try { IAsyncResult result = channel.BeginReceive(this.Parameters.ReceiveTimeout, null, null); message = channel.EndReceive(result); } catch (TimeoutException) { message = null; } } } else { if (this.Parameters.TryReceive) { bool ret = channel.TryReceive(this.Parameters.ReceiveTimeout, out message); lock (this.Results) { this.Results.Add(String.Format("TryReceive returned {0}", ret)); } } else { try { message = channel.Receive(this.Parameters.ReceiveTimeout); } catch (TimeoutException) { message = null; } } } } else { if (this.Parameters.TryReceive) { bool ret = false; if (this.Parameters.AsyncReceive) { IAsyncResult result = channel.BeginTryReceive(this.Parameters.ReceiveTimeout, null, null); if (this.Parameters.TryReceiveNullIAsyncResult) { try { channel.EndTryReceive(null, out message); } catch (Exception e) { lock (this.Results) { this.Results.Add(String.Format("TryReceive threw {0}", e.GetType().Name)); } } } ret = channel.EndTryReceive(result, out message); } else { ret = channel.TryReceive(this.Parameters.ReceiveTimeout, out message); } lock (this.Results) { this.Results.Add(String.Format("TryReceive returned {0}", ret)); this.Results.Add(String.Format("Message was {0}", (message == null ? "null" : "not null"))); } } message = null; } if (commit && message != null) { lock (this.Results) { this.Results.Add(String.Format("Received message with Action '{0}'", message.Headers.Action)); } ts.Complete(); } else { Transaction.Current.Rollback(); } } return message; }
public TypeSubscription(IInputChannel inputChannel, IMessageFilter messageFilter, ISubscriptionDispatcher dispatcher, object instance) : base(inputChannel, messageFilter, dispatcher) { _dispatcher = dispatcher; _instance = instance; }