本文整理汇总了C#中DuplexChannelFactory类的典型用法代码示例。如果您正苦于以下问题:C# DuplexChannelFactory类的具体用法?C# DuplexChannelFactory怎么用?C# DuplexChannelFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DuplexChannelFactory类属于命名空间,在下文中一共展示了DuplexChannelFactory类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: RobotClient
public RobotClient()
{
// Initilize communication channel
DuplexChannelFactory = new DuplexChannelFactory<IUiPathRemoteDuplexContract>(new InstanceContext(this), "DefaultDuplexEndpoint");
DuplexChannelFactory.Credentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;
Channel = DuplexChannelFactory.CreateChannel();
}
开发者ID:UiPath,项目名称:SDK,代码行数:7,代码来源:RobotClient.cs
示例2: 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
示例3: submitButton_Click
private void submitButton_Click(object sender, RoutedEventArgs e)
{
var login = loginTextBox.Text;
var pass = passwordTextBox.Password;
Action<String> status = s => {
statusLabel.Content = s;
statusLabel.ToolTip = s;
};
try {
channelFactory = new DuplexChannelFactory<IService>(new ClientImplementation(_MainWindow), "DnDServiceEndPoint");
server = channelFactory.CreateChannel();
if (server.Login(login, pass)) {
_MainWindow.InitializeServer(channelFactory, server);
this.DialogResult = true;
} else {
statusLabel.Content = "Login lub hasło nie są poprawne!";
return;
}
} catch (Exception ex) {
statusLabel.Content = "Nastąpił błąd! Spróbuj ponownie";
System.IO.StreamWriter file = new System.IO.StreamWriter("log.txt");
file.WriteLine(ex.ToString());
file.Close();
return;
}
this.Close();
}
开发者ID:kacpak,项目名称:Dungeons_and_Dragons,代码行数:31,代码来源:ClientLogin.xaml.cs
示例4: MainWindow
public MainWindow()
{
InitializeComponent();
EndpointAddress endpointAddress = new EndpointAddress("http://localhost:31337/BesiegedServer/BesiegedMessage");
DuplexChannelFactory<IBesiegedServer> duplexChannelFactory = new DuplexChannelFactory<IBesiegedServer>(m_Client, new WSDualHttpBinding(), endpointAddress);
m_BesiegedServer = duplexChannelFactory.CreateChannel();
// Subscribe in a separate thread to preserve the UI thread
Task.Factory.StartNew(() =>
{
CommandConnect commandConnect = new CommandConnect();
m_BesiegedServer.SendMessage(commandConnect.ToXml());
});
Task.Factory.StartNew(() =>
{
while (true)
{
Command command = m_Client.MessageQueue.Take();
ProcessMessage(command);
}
}, TaskCreationOptions.LongRunning);
GameLobbyCollection = new ObservableCollection<CommandNotifyGame>();
DataContext = this;
}
开发者ID:WonderPanda,项目名称:Besieged,代码行数:27,代码来源:MainWindow.xaml.cs
示例5: RegisterViewModel
public RegisterViewModel()
{
var channelFactory = new DuplexChannelFactory<IChattingService>(new ClientService(), "ChattingServiceEndPoint");
_server = channelFactory.CreateChannel();
Register = new RelayCommand(OnRegister, () => !(string.IsNullOrEmpty(UserName) || string.IsNullOrEmpty(Password)));
ClearCommand = new RelayCommand(OnClear);
}
开发者ID:DavidNemeth,项目名称:DesktopApps,代码行数:7,代码来源:RegisterViewModel.cs
示例6: ConnectIpc
public static void ConnectIpc(IServiceRemotingCallback serviceRemotingCallback)
{
InstanceContext instanceContext = new InstanceContext(serviceRemotingCallback);
PipeFactory = new DuplexChannelFactory<IServiceRemoting>(instanceContext, new NetNamedPipeBinding(), new EndpointAddress("net.pipe://localhost/BitCollectors.PlinkService/PlinkService"));
RemotingObject = PipeFactory.CreateChannel();
}
开发者ID:tk-s,项目名称:BitCollectors.PlinkService,代码行数:7,代码来源:WcfClientHelper.cs
示例7: MonitorForm_Load
//其他成员
private void MonitorForm_Load(object sender, EventArgs e)
{
string header = string.Format("{0, -13}{1, -22}{2}", "Client", "Time", "Event");
this.listBoxExecutionProgress.Items.Add(header);
_syncContext = SynchronizationContext.Current;
_callbackInstance = new InstanceContext(new CalculatorCallbackService());
_channelFactory = new DuplexChannelFactory<ICalculator>(_callbackInstance, "calculatorservice");
EventMonitor.MonitoringNotificationSended += ReceiveMonitoringNotification;
this.Disposed += delegate
{
EventMonitor.MonitoringNotificationSended -= ReceiveMonitoringNotification;
_channelFactory.Close();
};
for (int i = 0; i < 2; i++)
{
ThreadPool.QueueUserWorkItem(state =>
{
int clientId = Interlocked.Increment(ref _clientId);
EventMonitor.Send(clientId, EventType.StartCall);
ICalculator proxy = _channelFactory.CreateChannel();
using (OperationContextScope contextScope = new OperationContextScope(proxy as IContextChannel))
{
MessageHeader<int> messageHeader = new MessageHeader<int>(clientId);
OperationContext.Current.OutgoingMessageHeaders.Add(messageHeader.GetUntypedHeader(EventMonitor.CientIdHeaderLocalName, EventMonitor.CientIdHeaderNamespace));
proxy.Add(1, 2);
}
EventMonitor.Send(clientId, EventType.EndCall);
}, null);
}
}
开发者ID:huoxudong125,项目名称:WCF-Demo,代码行数:33,代码来源:MonitorForm.cs
示例8: Connect
/// <summary>
/// Connect to game server
/// </summary>
/// <param name="IP"></param>
/// <returns></returns>
public bool Connect(String IP)
{
// Create a pipeFactory
DuplexChannelFactory<IMessage> pipeFactory =
new DuplexChannelFactory<IMessage>(
new InstanceContext(this),
new NetTcpBinding(),
//new EndpointAddress(String.Format("net.tcp://{0}:8000/GameServer", IP)));
new EndpointAddress(String.Format("net.tcp://{0}:8000/GameServer", "localhost")));
try
{
// Creating the communication channel
pipeProxy = pipeFactory.CreateChannel();
// register for events
pipeProxy.Subscribe();
// join the game
myID = pipeProxy.join(me.Username, me.money, me.numOfGames, me.ID);
if (pipeProxy.runningGame())
{
pipeProxy.resetGame();
}
return true;
}
catch (Exception e)
{
return false;
}
}
开发者ID:srgrn,项目名称:BlackJack.Net,代码行数:36,代码来源:GameScreen.cs
示例9: Test
public static void Test()
{
string baseAddress = "net.tcp://" + Environment.MachineName + ":8000/Service";
ServiceHost host = new ServiceHost(typeof(Service), new Uri(baseAddress));
host.AddServiceEndpoint(typeof(ITest), new NetTcpBinding(SecurityMode.None), "");
host.Open();
Console.WriteLine("Host opened");
AutoResetEvent evt = new AutoResetEvent(false);
MyCallback callback = new MyCallback(evt);
DuplexChannelFactory<ITest> factory = new DuplexChannelFactory<ITest>(
new InstanceContext(callback),
new NetTcpBinding(SecurityMode.None),
new EndpointAddress(baseAddress));
ITest proxy = factory.CreateChannel();
Console.WriteLine(proxy.Hello("foo bar"));
evt.WaitOne();
((IClientChannel)proxy).Close();
factory.Close();
Console.Write("Press ENTER to close the host");
Console.ReadLine();
host.Close();
}
开发者ID:ravish27,项目名称:WCFQuickSamples,代码行数:26,代码来源:Templates.cs
示例10: MainWindow
public MainWindow()
{
try
{
//Center the window on startup
WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen;
InitializeComponent();
createGrid();
// Configure the Endpoint details
DuplexChannelFactory<ITileBag> channel = new DuplexChannelFactory<ITileBag>(this, "TileBag");
// Activate a remote Bag object
bag = channel.CreateChannel();
// Register this client for the callback service
bag.RegisterForCallbacks();
lblPlayerScore.Content = 0;
pWin = new PlayerLobby(this, bag.ClientCount);
pWin.Show();
this.Hide();
}
catch (Exception ex)
{
MessageBox.Show("Error Initializing Window " + ex.Message);
}
}
开发者ID:Jardjard,项目名称:Scrabblesque,代码行数:26,代码来源:MainWindow.xaml.cs
示例11: Main
static void Main(string[] args)
{
var fact = new ChannelFactory<IDeviceManagerService>("deviceEndpoint");
InstanceContext callback = new InstanceContext(new ServiceCallback());
var dup = new DuplexChannelFactory<ICardReaderEventsSubscribe>(callback, "dupSocket");
var cardReaderSub = dup.CreateChannel();
var cha = fact.CreateChannel();
using (fact)
{
var devices = cha.GetAllDevices();
//cha.Open(new devices[0].FullSerialNumber );
}
Console.WriteLine("try a new");
Console.ReadKey();
Console.WriteLine("REading duplex");
cardReaderSub.SubscribeToCardSwipeByhost("Local");
Console.ReadKey();
var fact1 = new ChannelFactory<IDeviceManagerService>("deviceEndpoint");
var cha1 = fact1.CreateChannel();
using (fact1)
{
var devices = cha1.GetAllDevices();
}
}
开发者ID:goodwillguy,项目名称:DeviceManagerService,代码行数:35,代码来源:Program.cs
示例12: StartP2PClient
private void StartP2PClient( )
{
string s = ConfigurationManager.AppSettings["IsSupportGroup"];
if (s.Equals("no", StringComparison.OrdinalIgnoreCase))
{
return;
}
InstanceContext context = new InstanceContext(new P2PChatService());
DuplexChannelFactory<IP2PChatService> factory = new DuplexChannelFactory<IP2PChatService>(context,"p2p", new EndpointAddress("net.p2p://" + groupId));
channel = factory.CreateChannel();
clients.Add(groupId, this);
new Thread(new ThreadStart(() =>
{
try
{
channel.Join();
}
catch (Exception ex)
{
MyLogger.Logger.Error("进入群组聊天室时出错",ex);
}
})).Start();
}
开发者ID:ITPuppy,项目名称:myRepo,代码行数:29,代码来源:P2PClient.cs
示例13: ClientViewModel
public ClientViewModel()
{
var channelFactory = new DuplexChannelFactory<IChattingService>(new ClientService(), "ChattingServiceEndPoint");
_server = channelFactory.CreateChannel();
This = this;
CreateCommands();
}
开发者ID:DavidNemeth,项目名称:DesktopApps,代码行数:7,代码来源:ClientViewModel.cs
示例14: TestOneWayCallbackConcurencyOnNamedPipe
public void TestOneWayCallbackConcurencyOnNamedPipe()
{
var address = @"net.pipe://127.0.0.1/testpipename" + MethodBase.GetCurrentMethod().Name;
var srv = new CallbackService();
var callback = new CallbackServiceCallback();
using (var server = new ServiceHost(srv, new Uri(address)))
{
server.AddServiceEndpoint(typeof(ICallbackService), new NetNamedPipeBinding { }, address);
server.Open();
using (var channelFactory = new DuplexChannelFactory<ICallbackService>(new InstanceContext(callback), new NetNamedPipeBinding { }))
{
var client = channelFactory.CreateChannel(new EndpointAddress(address));
for (int i = 0; i < 20; i++)
client.OneWayExecute();
while (callback.Count != 20)
{
Thread.Sleep(10);
}
}
}
}
开发者ID:OpenSharp,项目名称:NDceRpc,代码行数:25,代码来源:ConcurrencyTests.cs
示例15: NetTcpBinding_DuplexCallback_ReturnsXmlComplexType
public static void NetTcpBinding_DuplexCallback_ReturnsXmlComplexType()
{
DuplexChannelFactory<IWcfDuplexService_Xml> factory = null;
NetTcpBinding binding = null;
WcfDuplexServiceCallback callbackService = null;
InstanceContext context = null;
IWcfDuplexService_Xml serviceProxy = null;
Guid guid = Guid.NewGuid();
try
{
binding = new NetTcpBinding();
binding.Security.Mode = SecurityMode.None;
callbackService = new WcfDuplexServiceCallback();
context = new InstanceContext(callbackService);
factory = new DuplexChannelFactory<IWcfDuplexService_Xml>(context, binding, new EndpointAddress(Endpoints.Tcp_NoSecurity_XmlDuplexCallback_Address));
serviceProxy = factory.CreateChannel();
serviceProxy.Ping_Xml(guid);
XmlCompositeTypeDuplexCallbackOnly returnedType = callbackService.XmlCallbackGuid;
// validate response
Assert.True((guid.ToString() == returnedType.StringValue), String.Format("The Guid to string value sent was not the same as what was returned.\nSent: {0}\nReturned: {1}", guid.ToString(), returnedType.StringValue));
((ICommunicationObject)serviceProxy).Close();
factory.Close();
}
finally
{
ScenarioTestHelpers.CloseCommunicationObjects((ICommunicationObject)serviceProxy, factory);
}
}
开发者ID:roncain,项目名称:wcf,代码行数:34,代码来源:DataContractTests.4.1.0.cs
示例16: Main
static void Main(string[] args)
{
try
{
DuplexChannelFactory<IServerWithCallback> cf =
new DuplexChannelFactory<IServerWithCallback>(
new CallbackImpl(),
new NetTcpBinding(),
new EndpointAddress("net.tcp://192.168.1.1:9078/DataService"));
IServerWithCallback srv = cf.CreateChannel();
CounterStatues cs = new CounterStatues { CounterName = "Counter eeee", CounterNumber = "ttt", CounterStatus =CounterStatues.CounterStatusEn.Lock, UserId = "yahoo", IpAddress = "192.168.50.90" };
srv.StartDataOutput(cs);
System.Threading.ParameterizedThreadStart pt = new System.Threading.ParameterizedThreadStart(ServerChecker);
System.Threading.Thread checkserver = new System.Threading.Thread(pt);
checkserver.Start(srv);
Console.Read();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
Console.WriteLine("Try again ...");
System.Threading.Thread.Sleep(600);
Main(null);
}
}
开发者ID:shuvo009,项目名称:CafeteriaVernier,代码行数:26,代码来源:Program.cs
示例17: Main
static void Main(string[] args)
{
Console.Title = "Client";
Console.WriteLine("Press any key to connect to server");
Console.ReadKey();
// InstanceContext - представляет метод вызываемый сервисом на клиенте.
InstanceContext context = new InstanceContext(new Context());
// Создаем фабрику дуплексных каналов на клиенте.
DuplexChannelFactory<IContractService> factory = new DuplexChannelFactory<IContractService>(
context,
new NetTcpBinding(),
"net.tcp://localhost:9000/MyService"
);
// Создаем конкретный канал.
IContractService server = factory.CreateChannel();
server.ServerMethod();
Console.WriteLine("Connected");
Console.ReadKey();
Console.ReadKey();
}
开发者ID:master-vk,项目名称:Tasks-ITVDN,代码行数:30,代码来源:Program.cs
示例18: RemoteExecutorClient
public RemoteExecutorClient(string hostname)
{
_executorServiceCallback = new RemoteExecutorCallback();
var context = new InstanceContext(_executorServiceCallback);
// TODO: Process more than this single Endpoint named "NetTcpBinding_IExecutorService".
// What about InstanceContext. Do we need another one if more than one Endpoint is parameterized.
// Will it be usefull to offer more than one endpoint?
// -> It will be usefull. What about offering chooseable predefined Endpoints? Eg.: NamedPipe or TCP.
// .) NamedPipe will be used for local Executors or for the "Send a message to the Executor" Service.
// .) TCP will be used for Executors on other machines.
var uri = new Uri("net.tcp://" + hostname + ":9000/RExServer");
EndpointIdentity identity = EndpointIdentity.CreateSpnIdentity("RExTheMighty");
_channelFactory = new DuplexChannelFactory<IRemoteExecutor>(
context, new NetTcpBinding(), new EndpointAddress(uri, identity));
_reconnectTimer = new System.Timers.Timer(ReconnectTimeout) {AutoReset = false}; // Wait after channel failure before reconnect.
_reconnectTimer.Elapsed += (s, e) =>
{
try
{
if (!_isConnected)
{
Connect();
}
}
catch (Exception ex)
{
Log.Trace("Failed to reconnect: "+ ex.Message);
}
};
_isConnected = false;
}
开发者ID:TestExperience,项目名称:REx,代码行数:34,代码来源:RemoteExecutorClient.cs
示例19: Connect
public bool Connect(ClientCrawlerInfo clientCrawlerInfo)
{
try
{
var site = new InstanceContext(this);
var binding = new NetTcpBinding(SecurityMode.None);
//var address = new EndpointAddress("net.tcp://localhost:22222/chatservice/");
var address = new EndpointAddress("net.tcp://193.124.113.235:22222/chatservice/");
var factory = new DuplexChannelFactory<IRemoteCrawler>(site, binding, address);
proxy = factory.CreateChannel();
((IContextChannel)proxy).OperationTimeout = new TimeSpan(1, 0, 10);
clientCrawlerInfo.ClientIdentifier = _singletoneId;
proxy.Join(clientCrawlerInfo);
return true;
}
catch (Exception ex)
{
MessageBox.Show("Error happened" + ex.Message);
return false;
}
}
开发者ID:8ezhikov,项目名称:Git4Life,代码行数:27,代码来源:ProxySingletone.cs
示例20: CallAsync_wait_done
public void CallAsync_wait_done()
{
var address = @"net.pipe://127.0.0.1/" + this.GetType().Name + "_" + MethodBase.GetCurrentMethod().Name;
var binding = new NetNamedPipeBinding();
var done = new ManualResetEvent(false);
var srv = new AsyncService(done);
var callback = new AsyncServiceCallback();
using (var host = new ServiceHost(srv, new Uri(address)))
{
host.AddServiceEndpoint(typeof(IAsyncService), binding, address);
host.Open();
ThreadPool.QueueUserWorkItem(_ =>
{
using (var factory = new DuplexChannelFactory<IAsyncService>(new InstanceContext(callback), binding))
{
var client = factory.CreateChannel(new EndpointAddress(address));
AsyncCallback act = (x) =>
{
Assert.AreEqual(x.AsyncState, 1);
};
var result = client.BeginServiceAsyncMethod(act, 1);
result.AsyncWaitHandle.WaitOne();
Assert.AreEqual(result.AsyncState, 1);
client.EndServiceAsyncMethod(result);
}
});
done.WaitOne();
}
}
开发者ID:OpenSharp,项目名称:NDceRpc,代码行数:34,代码来源:AsyncTests.cs
注:本文中的DuplexChannelFactory类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论