コード例 #1
0
 public bool Execute()
 {
     try
     {
         _tcpClient = new TcpClient();
         _tcpClient.Connect(CreateEndpoint());
         _adapter = new PipeAdapter(_tcpClient.GetStream());
         return(true);
     }
     catch (Exception e)
     {
         Log.Error(e);
         return(false);
     }
 }
コード例 #2
0
        private PipeAdapter CreatePipeAdapter(TcpClient client)
        {
            var adapter = new PipeAdapter(client.GetStream());

            Task.Run(() => adapter.ExecuteAsync(_cts.Token));

            adapter.WhenReceived
            .Select(d => new NetworkContent(_receiver.Encoding.GetString(d.ToArray()), client.Client.RemoteEndPoint))
            .Subscribe(SequenceReceived);

            adapter.WhenTerminated
            .Select(d => (adapter, client.Client.RemoteEndPoint))
            .Subscribe(Disconnect);

            return(adapter);
        }