Exemplo n.º 1
0
        /// <summary>
        /// 进行数据连接
        /// </summary>
        /// <param name="port"></param>
        /// <returns></returns>
        public async Task Connect(
            [SuitParser(typeof(Parsers), nameof(Parsers.ParseInt))]
            int port)
        {
            DataStream = await RdtStream.CreateClientAsync(
                Config, new IPEndPoint(Ip, port));

            await IO.WriteLineAsync($"Connect {DataStream?.Port ?? -1}");
        }
Exemplo n.º 2
0
        public async Task Connect(
            [SuitParser(typeof(LftpClient), nameof(ParseIp))]
            IPAddress ip,
            [SuitParser(typeof(Parsers), nameof(Parsers.ParseInt))]
            int port)
        {
            if (Controller != null)
            {
                await Controller.WriteLineAsync("Exit");
            }

            ControllerStream = await RdtStream.CreateClientAsync(
                Config, new IPEndPoint(ip, port));

            if (ControllerStream == null)
            {
                await IO.WriteLineAsync($"连接服务器失败。");

                return;
            }

            Controller = new StreamWriter(ControllerStream)
            {
                AutoFlush = true
            };
            var cc = new LftpClientController(Config);

            Task.Run(() =>
            {
                Suit.GetBuilder()
                .ConfigureIn(new StreamReader(ControllerStream))
                .UseLog(ILogger.OfFile($"ClientController-{cc.ListenerPort}.log"))
                .Build(cc)
                .Run();
            }).GetAwaiter();
            await Controller.WriteLineAsync($"Connect {cc.ListenerPort}");
        }
Exemplo n.º 3
0
 public LftpClientController(RdtConfig config)
 {
     Listener = RdtStream.CreateListener(config);
     //Ip = endPoint?.Address ?? IPAddress.Loopback;
     Config = config;
 }
Exemplo n.º 4
0
 public LftpServer(RdtConfig config, int port = 0)
 {
     Listener = RdtStream.CreateListener(config, port);
     Config   = config;
     Run().GetAwaiter();
 }