public void Receive_from_standIn() { var cre = PubnubCredentials.LoadFrom("pubnub credentials.txt"); using (var sut = new PubnubHostTransceiver(cre, "hostchannel")) { var are = new AutoResetEvent(false); HostInput result = null; sut.ReceivedFromStandIn += _ => { result = _; are.Set(); }; var standIn = new Pubnub(cre.PublishingKey, cre.SubscriptionKey, cre.SecretKey); var hi = new HostInput { CorrelationId = Guid.NewGuid(), Data = "hello".Serialize(), Portname = "portname", StandInEndpointAddress = "endpoint" }; standIn.publish("hostchannel", hi.Serialize(), _ => { }); Assert.IsTrue(are.WaitOne(5000)); Assert.AreEqual(hi.CorrelationId, result.CorrelationId); Assert.AreEqual(hi.Data, result.Data); Assert.AreEqual(hi.Portname, result.Portname); Assert.AreEqual(hi.StandInEndpointAddress, result.StandInEndpointAddress); } }
public void Run() { var config = new FlowRuntimeConfiguration() .AddEventBasedComponent("Op", new Op()) .AddStream(".receive@op", "op.receive") .AddStream("op.send", ".send@op"); using (var fr = new FlowRuntime(config, new Schedule_for_sync_depthfirst_processing())) { fr.Message += Console.WriteLine; var sut = new HostTranslator(); sut.Translated_input += fr.Process; fr.Result += sut.Process_local_output; Tuple <string, HostOutput> result = null; sut.Translated_output += _ => result = _; var input = new HostInput { CorrelationId = Guid.NewGuid(), Data = "hello".Serialize(), Portname = "op.receive", StandInEndpointAddress = "localhost:1234" }; sut.Process_remote_input(input); Assert.AreEqual("localhost:1234", result.Item1); Assert.AreEqual(input.CorrelationId, result.Item2.CorrelationId); Assert.AreEqual("<hello>".Serialize(), result.Item2.Data); Assert.AreEqual("op.send", result.Item2.Portname); } }
public void Process_remote_input(HostInput input) { _cache.Add(input.CorrelationId, input.StandInEndpointAddress); var msg = new Message(input.Portname.StandInPortnameToInputPortname(), input.Data.Deserialize(), input.CorrelationId); Translated_input(msg); }
void ProcessOnHost(HostInput input, Action<HostOutput> sendOutput) { Assert.AreEqual("localhost:1234", input.StandInEndpointAddress); var inputPort = new Port(input.Portname); // remoteOp.inputPort var outputPortname = string.Format(inputPort.OperationName + "." + inputPort.Name + "-out"); // remoteOp.outputPort var output = new HostOutput { CorrelationId = input.CorrelationId, Data = ("<" + input.Data.Deserialize() + ">").Serialize(), Portname = outputPortname}; sendOutput(output); }
/// <inheritdoc /> public virtual void Dispose() { FpsCounter.Dispose(); FpsCounter = default; HostInput.Dispose(); HostInput = default; HostHandle = default; }
public Host(IServiceProvider services, IServiceCollection pool, IAppBuilder appBuilder, IEnvironment hostEnv, IOutputEngine output, IHostInput hostInput, IHistoryProvider historyProvider) { this.services = services; this.pool = pool; this.appBuilder = appBuilder; this.hostEnv = hostEnv; this.output = output; this.hostInput = hostInput as HostInput; this.historyProvider = historyProvider; }
void ProcessOnHost(HostInput input, Action <HostOutput> sendOutput) { Assert.AreEqual("localhost:1234", input.StandInEndpointAddress); var inputPort = new Port(input.Portname); // remoteOp.inputPort var outputPortname = string.Format(inputPort.OperationName + "." + inputPort.Name + "-out"); // remoteOp.outputPort var output = new HostOutput { CorrelationId = input.CorrelationId, Data = ("<" + input.Data.Deserialize() + ">").Serialize(), Portname = outputPortname }; sendOutput(output); }
public void Process_local_output(IMessage outputMsg) { var corrId = Guid.NewGuid(); var ctx = new FlowContext { Path = outputMsg.Port.Path, StandInOperationName = outputMsg.Port.OperationName, CorrelationId = outputMsg.CorrelationId, Priority = outputMsg.Priority, Causalities = outputMsg.Causalities, FlowStack = outputMsg.FlowStack }; _cache.Add(corrId, ctx); var input = new HostInput { Portname = outputMsg.Port.OutputPortToRemotePortname(), Data = outputMsg.Data.Serialize(), CorrelationId = corrId, StandInEndpointAddress = _standInEndpointAddress }; Translated_output(input); }
public void StandIn_to_Host() { using (var host = new WcfHostTransceiver("localhost:8000")) using (var standIn = new WcfStandInTransceiver("localhost:8001", "localhost:8000")) { HostInput input = null; host.ReceivedFromStandIn += _ => input = _; standIn.SendToHost(new HostInput { Data = new byte[] { 4, 2 } }); Assert.AreEqual(new byte[] { 4, 2 }, input.Data); } }
/// <inheritdoc /> public virtual void Dispose() { HostInput.SizeChanged -= HostInputOnSizeChanged; FpsCounter.Dispose(); FpsCounter = default; BufferSize = default; ViewportSize = default; HostInput.Dispose(); HostInput = default; HostHandle = default; }
public override bool Validate() { var password = HostInput.GetBindingExpression(TextBox.TextProperty); if (password != null) { password.UpdateSource(); if (string.IsNullOrEmpty(HostInput.Text)) { Validation.MarkInvalid(password, PasswordRequired); Helpers.ShowError(HostInput); return(false); } } return(base.Validate()); }
public void Send_to_host() { var cre = PubnubCredentials.LoadFrom("pubnub credentials.txt"); var host = new Pubnub(cre.PublishingKey, cre.SubscriptionKey); try { var are = new AutoResetEvent(false); ReadOnlyCollection <object> result = null; host.subscribe("hostchannel", (ReadOnlyCollection <object> _) => { result = _; are.Set(); }); using (var sut = new PubnubStandInTransceiver(cre, "hostchannel")) { var hi = new HostInput { CorrelationId = Guid.NewGuid(), Data = "hello".Serialize(), Portname = "portname", StandInEndpointAddress = "endpoint" }; sut.SendToHost(hi); Assert.IsTrue(are.WaitOne(5000)); var hiReceived = Convert.FromBase64String((string)((JValue)result[0]).Value).Deserialize() as HostInput; Assert.AreEqual(hi.CorrelationId, hiReceived.CorrelationId); Assert.AreEqual(hi.Data, hiReceived.Data); Assert.AreEqual(hi.Portname, hiReceived.Portname); Assert.AreEqual(hi.StandInEndpointAddress, hiReceived.StandInEndpointAddress); } } finally { host.unsubscribe("hostchannel", _ => {}); } }
internal void ChannelFromStandIn(HostInput input) { ReceivedFromStandIn(input); }
void SendFromStandInToHost(string hostName, HostInput input) { _hosts[hostName].ChannelFromStandIn(input); }
public void SendToHost(HostInput input) { _host.Process(input); }
protected virtual string ReadLine(string hint) { OutputEngine.WriteHint(hint + ": "); return(HostInput.ReadLine()); }
public void SendToHost(HostInput input) { _channelToHost(_hostName, input); }
public void SendToHost(HostInput input) { var serializedInput = input.Serialize(); _transceiver.publish(_hostChannel, serializedInput, _ => { }); }