private static async void SendMessages(Binding binding, int messageCount, string address) { var factory = binding.BuildChannelFactory<IDuplexSessionChannel>(); try { factory.Open(); var channel = factory.CreateChannel(new EndpointAddress(address)); channel.Open(); Console.WriteLine("Channel should be connected by now..."); var sendBytes = Encoding.ASCII.GetBytes("Hello WCF over a channel"); var message = Message.CreateMessage(binding.MessageVersion, "action", sendBytes); var clone = message.CreateBufferedCopy(int.MaxValue); for (int i = 0; i < messageCount; i++) { await Task.Factory.FromAsync(channel.BeginSend(clone.CreateMessage(), null, null), channel.EndSend); } channel.Close(); } finally { factory.Close(); } }
public DuplexChannelManager(int connections, int messageRate, Binding binding, string address, MessageBuffer messageBuffer = null) { _connections = connections; _rate = messageRate; _factory = binding.BuildChannelFactory<IDuplexSessionChannel>(); _address = new EndpointAddress(address); _messageBuffer = messageBuffer ?? Message.CreateMessage(binding.MessageVersion, "TestAction", new byte[1024]).CreateBufferedCopy(int.MaxValue); ; _factory.Open(); }
public ClientBase(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) { //this.remoteAddress = remoteAddress; this.messageVersion = binding.MessageVersion; IChannelFactory <IRequestChannel> channelFactory = binding.BuildChannelFactory <IRequestChannel>( new BindingParameterCollection()); channelFactory.Open(); this.requestChannel = channelFactory.CreateChannel(remoteAddress); }