public object Call(MessageContract contract) { if (_client.SendAsync(contract).Wait(ConfigurableTimeout)) { return(_client.ReceiveAsync().Result); } throw new Exception(string.Format("Error invoking {0} remote service method.", contract.MethodName)); }
static void Main(string[] args) { var server = new ChannelTcpListener(); server.MessageReceived = OnServerReceivedMessage; server.Start(IPAddress.Any, 0); var client = new ChannelTcpClient <object>(new MicroMessageEncoder(new DataContractMessageSerializer()), new MicroMessageDecoder(new DataContractMessageSerializer())); client.ConnectAsync(IPAddress.Loopback, server.LocalPort).Wait(); client.SendAsync(new FileStream("TextSample.txt", FileMode.Open)).Wait(); Console.ReadLine(); }
public async Task ExecuteAsync <T>(T command) where T : Command { await EnsureConnected(); try { var waiter = new Waiter <T>(command.CommandId); _response[command.CommandId] = waiter; await _client.SendAsync(command); await waiter.Task; } catch (Exception) { throw; } }
private Task SendItem(object item) { _lastSentItem = item; return(_client.SendAsync(item)); }