当前位置: 首页>>代码示例>>C#>>正文


C# Proxy.Start方法代码示例

本文整理汇总了C#中System.Proxy.Start方法的典型用法代码示例。如果您正苦于以下问题:C# Proxy.Start方法的具体用法?C# Proxy.Start怎么用?C# Proxy.Start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Proxy的用法示例。


在下文中一共展示了Proxy.Start方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

        static void Main(string[] args)
        {
            IPAddress ip = null;
            int port = 0;

            var p = new OptionSet()
            .Add("a|address=", v => ip = IPAddress.Parse(v))
            .Add("p|port=", v => port = int.Parse(v));

            p.Parse(args);

            var proxy = new Proxy
            {
                ListenToIp = ip,
                ListenOnPort = port
            };
            proxy.Start();

            Console.WriteLine("Proxy is started ans listening on {0}:{1}", proxy.ListenToIp, proxy.ListenOnPort);
            Console.WriteLine("Press 'Q' to stop the proxy");

            while (true)
            {
                if (Console.KeyAvailable)
                {
                    var key = Console.ReadKey(true);
                    if (key.Key == ConsoleKey.Q)
                    {
                        proxy.Stop();
                        Console.WriteLine("Proxy is stopped");
                        break;
                    }
                }
            }
        }
开发者ID:JuergenGutsch,项目名称:async-proxy,代码行数:35,代码来源:Program.cs

示例2: DocumentationTests

        public DocumentationTests()
        {
            var processes = System.Diagnostics.Process.GetProcessesByName("Moksy.Host");
            Assert.AreEqual(1, processes.Length, "Moksy.Host is not running. Right click the Moksy.Host project, add 10011 to the Debug / Command Line Arguments and then run Moksy.Host without a debugger. Then try to run this test again. ");

            Proxy = new Proxy(PortNumber);
            Assert.IsTrue(Proxy.Start(), string.Format("Moksy could not start. Try to manually launch 'Moksy.Host.exe {0}' from the Command Line. ", PortNumber));
            Proxy.DeleteAll();
        }
开发者ID:aidancasey,项目名称:Moksy,代码行数:9,代码来源:DocumentationTests.cs

示例3: Execute

        private void Execute()
        {
            var ip = Settings.Default.ListenIP;
            var port = Settings.Default.ListenPort;

            var proxy = new Proxy
                {
                    ListenToIp = IPAddress.Parse(ip),
                    ListenOnPort = port
                };
            try
            {
                proxy.Start();
            }
            catch (Exception ex)
            {
                proxy.Stop();
                ServiceEventLog.WriteEntry(ex.ToString(), EventLogEntryType.Error);
                Logger.Log(ex);
            }
        }
开发者ID:JuergenGutsch,项目名称:async-proxy,代码行数:21,代码来源:CallProxy.cs

示例4: TestProxySendAndReceiveWithExternalPoller

        public void TestProxySendAndReceiveWithExternalPoller()
        {
            using (var context = NetMQContext.Create())
            using (var front = context.CreateRouterSocket())
            using (var back = context.CreateDealerSocket())
            using (var poller = new Poller(front, back))
            {
                front.Bind("inproc://frontend");
                back.Bind("inproc://backend");

                var proxy = new Proxy(front, back, null, poller);

                poller.PollTillCancelledNonBlocking();

                proxy.Start();

                using (var client = context.CreateRequestSocket())
                using (var server = context.CreateResponseSocket())
                {
                    client.Connect("inproc://frontend");
                    server.Connect("inproc://backend");

                    client.SendFrame("hello");
                    Assert.AreEqual("hello", server.ReceiveFrameString());
                    server.SendFrame("reply");
                    Assert.AreEqual("reply", client.ReceiveFrameString());

                    // Now stop the external poller
                    poller.CancelAndJoin();

                    client.SendFrame("anyone there?");

                    // Should no longer receive any messages
                    Assert.IsFalse(server.TrySkipFrame(TimeSpan.FromMilliseconds(50)));
                }
            }
        }
开发者ID:romanros,项目名称:netmq,代码行数:37,代码来源:ProxyTests.cs

示例5: ConfigureRemoteMachine

 public void ConfigureRemoteMachine()
 {
     Proxy proxy = new Proxy(10011);
     proxy.Start();
 }
开发者ID:aidancasey,项目名称:Moksy,代码行数:5,代码来源:ProxyTests.cs

示例6: StartNotRunning

 //[TestMethod]
 public void StartNotRunning()
 {
     Proxy proxy = new Proxy(20000);
     var result = proxy.Start();
     Assert.IsTrue(result);
 }
开发者ID:aidancasey,项目名称:Moksy,代码行数:7,代码来源:SimulationTests.cs

示例7: ThroughXPubXSubWithReconnectingPublisher

        public void ThroughXPubXSubWithReconnectingPublisher()
        {
            using (var xpub = new XPublisherSocket())
            using (var xsub = new XSubscriberSocket())
            using (var poller = new NetMQPoller {xsub, xpub})
            {
                var xPubPort = (ushort)xpub.BindRandomPort("tcp://*");
                var xSubPort = (ushort)xsub.BindRandomPort("tcp://*");

                var proxy = new Proxy(xsub, xpub, poller: poller);
                proxy.Start();

                poller.RunAsync();

                // long running subscriber
                using (var sub = new SubscriberSocket())
                {
                    sub.Connect(string.Format("tcp://localhost:{0}", xPubPort));
                    sub.Subscribe("A");

                    // publisher 1
                    using (var pub = new PublisherSocket())
                    {
                        pub.Connect(string.Format("tcp://localhost:{0}", xSubPort));
                        // give the publisher a chance to learn of the subscription
                        Thread.Sleep(100);
                        pub.SendMoreFrame("A").SendFrame("1");
                    }

                    // publisher 2
                    using (var pub = new PublisherSocket())
                    {
                        pub.Connect(string.Format("tcp://localhost:{0}", xSubPort));
                        // give the publisher a chance to learn of the subscription
                        Thread.Sleep(100);
                        pub.SendMoreFrame("A").SendFrame("2");
                    }

                    var frames = new List<string>();

                    Assert.True(sub.TryReceiveMultipartStrings(TimeSpan.FromSeconds(1), ref frames));
                    CollectionAssert.AreEqual(new[] { "A", "1" }, frames);

                    Assert.True(sub.TryReceiveMultipartStrings(TimeSpan.FromSeconds(1), ref frames));
                    CollectionAssert.AreEqual(new[] { "A", "2" }, frames);
                }
            }
        }
开发者ID:GrabCAD,项目名称:netmq,代码行数:48,代码来源:PubSubTests.cs

示例8: ThroughXPubXSub

        public void ThroughXPubXSub()
        {
            using (var xpub = new XPublisherSocket())
            using (var xsub = new XSubscriberSocket())
            using (var proxyPoller = new NetMQPoller {xsub, xpub})
            {
                var xPubPort = (ushort)xpub.BindRandomPort("tcp://*");
                var xSubPort = (ushort)xsub.BindRandomPort("tcp://*");

                var proxy = new Proxy(xsub, xpub, poller: proxyPoller);
                proxy.Start();

                proxyPoller.RunAsync();

                using (var pub = new PublisherSocket())
                using (var sub = new SubscriberSocket())
                {
                    // Client 1
                    sub.Connect(string.Format("tcp://localhost:{0}", xPubPort));
                    pub.Connect(string.Format("tcp://localhost:{0}", xSubPort));

                    sub.Subscribe("A");

                    // Client 2
                    Thread.Sleep(500);
                    pub.SendMoreFrame("A").SendFrame("Hello");

                    var frames = new List<string>();
                    Assert.True(sub.TryReceiveMultipartStrings(TimeSpan.FromSeconds(1), ref frames));
                    CollectionAssert.AreEqual(
                        new[] { "A", "Hello" },
                        frames);
                }
            }
        }
开发者ID:GrabCAD,项目名称:netmq,代码行数:35,代码来源:PubSubTests.cs


注:本文中的System.Proxy.Start方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。