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);
            }
        }
Esempio n. 2
0
        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);
            }
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
            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;
        }
Esempio n. 6
0
 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;
 }
Esempio n. 7
0
            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);
            }
Esempio n. 8
0
        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);
        }
Esempio n. 9
0
        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);
                }
        }
Esempio n. 10
0
        /// <inheritdoc />
        public virtual void Dispose()
        {
            HostInput.SizeChanged -= HostInputOnSizeChanged;

            FpsCounter.Dispose();
            FpsCounter = default;

            BufferSize   = default;
            ViewportSize = default;

            HostInput.Dispose();
            HostInput = default;

            HostHandle = default;
        }
Esempio n. 11
0
        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", _ => {});
            }
        }
Esempio n. 13
0
 internal void ChannelFromStandIn(HostInput input)
 {
     ReceivedFromStandIn(input);
 }
Esempio n. 14
0
 void SendFromStandInToHost(string hostName, HostInput input)
 {
     _hosts[hostName].ChannelFromStandIn(input);
 }
Esempio n. 15
0
 public void SendToHost(HostInput input)
 {
     _host.Process(input);
 }
Esempio n. 16
0
 protected virtual string ReadLine(string hint)
 {
     OutputEngine.WriteHint(hint + ": ");
     return(HostInput.ReadLine());
 }
Esempio n. 17
0
 public void SendToHost(HostInput input)
 {
     _channelToHost(_hostName, input);
 }
        public void SendToHost(HostInput input)
        {
            var serializedInput = input.Serialize();

            _transceiver.publish(_hostChannel, serializedInput, _ => { });
        }
Esempio n. 19
0
 public void SendToHost(HostInput input)
 {
     _channelToHost(_hostName, input);
 }
Esempio n. 20
0
 void SendFromStandInToHost(string hostName, HostInput input)
 {
     _hosts[hostName].ChannelFromStandIn(input);
 }
Esempio n. 21
0
 public void SendToHost(HostInput input)
 {
     _host.Process(input);
 }
Esempio n. 22
0
 internal void ChannelFromStandIn(HostInput input)
 {
     ReceivedFromStandIn(input);
 }