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


C# DuplexChannelFactory.Open方法代码示例

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


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

示例1: OrationiSlave

		public OrationiSlave()
		{
			Binding binding = new NetTcpBinding(SecurityMode.None);
			EndpointAddress defaultEndpointAddress = new EndpointAddress("net.tcp://localhost:57344/Orationi/Master/v1/");
			EndpointAddress discoveredEndpointAddress = DiscoverMaster();
			ContractDescription contractDescription = ContractDescription.GetContract(typeof(IOrationiMasterService));
			ServiceEndpoint serviceEndpoint = new ServiceEndpoint(contractDescription, binding, discoveredEndpointAddress ?? defaultEndpointAddress);
			var channelFactory = new DuplexChannelFactory<IOrationiMasterService>(this, serviceEndpoint);

			try
			{
				channelFactory.Open();
			}
			catch (Exception ex)
			{
				channelFactory?.Abort();
			}

			try
			{
				_masterService = channelFactory.CreateChannel();
				_communicationObject = (ICommunicationObject)_masterService;
				_communicationObject.Open();
			}
			catch (Exception ex)
			{
				if (_communicationObject != null && _communicationObject.State == CommunicationState.Faulted)
					_communicationObject.Abort();
			}
		}
开发者ID:Rankcore,项目名称:Orationi,代码行数:30,代码来源:OrationiSlave.cs

示例2: OnBrowserCreated

        public override void OnBrowserCreated(CefBrowserWrapper browser)
        {
            browsers.Add(browser);

            if (parentBrowserId == null)
            {
                parentBrowserId = browser.BrowserId;
            }

            if (ParentProcessId == null || parentBrowserId == null)
            {
                return;
            }

            var browserId = browser.IsPopup ? parentBrowserId.Value : browser.BrowserId;

            var serviceName = RenderprocessClientFactory.GetServiceName(ParentProcessId.Value, browserId);

            var binding = BrowserProcessServiceHost.CreateBinding();

            var channelFactory = new DuplexChannelFactory<IBrowserProcess>(
                this,
                binding,
                new EndpointAddress(serviceName)
            );

            channelFactory.Open();

            var browserProcess = channelFactory.CreateChannel();
            var clientChannel = ((IClientChannel)browserProcess);

            try
            {
                clientChannel.Open();
                if (!browser.IsPopup)
                {
                    browserProcess.Connect();
                }

                var javascriptObject = browserProcess.GetRegisteredJavascriptObjects();

                if (javascriptObject.MemberObjects.Count > 0)
                {
                    browser.JavascriptRootObject = javascriptObject;
                }

                browser.ChannelFactory = channelFactory;
                browser.BrowserProcess = browserProcess;
            }
            catch(Exception)
            {
            }
        }
开发者ID:numbersint,项目名称:CefSharp,代码行数:53,代码来源:CefRenderProcess.cs

示例3: chatForm

        public chatForm(int port, string usernme)
        {
            InitializeComponent();
            DuplexChannelFactory<Chatroom> dupFactory = null;

            TextChatter _chatter = new TextChatter(this);
            dupFactory = new DuplexChannelFactory<Chatroom>(
                _chatter, new NetTcpBinding(), new EndpointAddress("net.tcp://localhost:" + port + "/Chat"));
            dupFactory.Open();
            clientProxy = dupFactory.CreateChannel();
            username = usernme;
            clientProxy.join(username);
        }
开发者ID:HelloItsDev,项目名称:Chat,代码行数:13,代码来源:chatForm.cs

示例4: CreateChannel_EndpointAddress_Null_Throws

    public static void CreateChannel_EndpointAddress_Null_Throws()
    {
        WcfDuplexServiceCallback callback = new WcfDuplexServiceCallback();
        InstanceContext context = new InstanceContext(callback);
        Binding binding = new NetTcpBinding();
        EndpointAddress remoteAddress = null;

        DuplexChannelFactory<IWcfDuplexService> factory = new DuplexChannelFactory<IWcfDuplexService>(context, binding, remoteAddress);
        try {
            Assert.Throws<InvalidOperationException>(() =>
               {
                   factory.Open();
                   factory.CreateChannel();
               });
        }
        finally
        { 
            factory.Abort();
        }
    }
开发者ID:wl0240407225,项目名称:wcf,代码行数:20,代码来源:DuplexChannelFactoryTest.cs

示例5: Main

	public static void Main ()
	{
		var binding = new NetPeerTcpBinding ();
		binding.Resolver.Mode = PeerResolverMode.Custom;
		binding.Resolver.Custom.Address = new EndpointAddress ("net.tcp://localhost:8086");
		var tcp = new NetTcpBinding () { TransactionFlow = false };
		tcp.Security.Mode = SecurityMode.None;
		binding.Resolver.Custom.Binding = tcp;

		binding.Security.Mode = SecurityMode.None;
		IFooChannel proxy = new DuplexChannelFactory<IFooChannel> (
			new Foo (),
			binding,
			new EndpointAddress ("net.p2p://samplemesh/SampleService")
			).CreateChannel ();
		proxy.Open ();
		proxy.SendMessage ("TEST FOR ECHO");
		Console.WriteLine (proxy.SessionId);
		Console.WriteLine ("type [CR] to quit");
		Console.ReadLine ();
	}
开发者ID:alesliehughes,项目名称:olive,代码行数:21,代码来源:samplecli6.cs

示例6: joinChatroom

        private static void joinChatroom(int port, string username)
        {
            DuplexChannelFactory<Chatroom> dupFactory = null;
            Chatroom clientProxy = null;
            TextChatter _chatter = new TextChatter();
            dupFactory = new DuplexChannelFactory<Chatroom>(
                _chatter, new NetTcpBinding(), new EndpointAddress("net.tcp://localhost:"+ port +"/Chat"));
            dupFactory.Open();
            clientProxy = dupFactory.CreateChannel();

            Console.WriteLine("Bienvenue dans la room {0}",username);
            clientProxy.join(username);
            string input = null;
            while (input != "exit")
            {
                input = Console.ReadLine();
                clientProxy.send(input, username);
                Console.SetCursorPosition(0, Console.CursorTop - 2);
                ClearCurrentConsoleLine();
                Console.SetCursorPosition(0, Console.CursorTop + 2);
            }

            dupFactory.Close();
        }
开发者ID:HelloItsDev,项目名称:Chat,代码行数:24,代码来源:Program.cs


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