本文整理汇总了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();
}
}
示例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)
{
}
}
示例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);
}
示例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();
}
}
示例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 ();
}
示例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();
}