public async Task <IActionResult> Start([FromRoute] string id)// TODO 使用202异步处理
        {
            var task = await currentservice.Find(x => x.Id == id);

            var line = await lineService.Find(x => x.Id == task.LineId);

            var client = await tcpClientFactory.CreateTcpClient();

            var session = await client.ConnectAsync(task.Ip, task.Port, task.SimNumber);

            var result = await session.StartTask(line.Id, task.Speed, task.Interval);

            return(Ok(new JsonResultDto <bool> {
                Flag = result, Data = result
            }));
        }
Esempio n. 2
0
 public BranchTcpServerHandler(ILogger <BranchTcpServerHandler> logger, IServerSessionManager serverSessionManager, ITcpClientFactory tcpClientFactory, ITcpClientManager tcpClientManager, IOptions <GatewayConfiguration> options)
 {
     this.logger               = logger;
     this.tcpClientManager     = tcpClientManager;
     this.serverSessionManager = serverSessionManager;
     configuration             = options.Value;
     Parallel.ForEach(configuration.BrabchServer, x => tcpClientFactory.CreateTcpClient(x.MatchId));
 }
Esempio n. 3
0
        public async Task <IActionResult> IndexAsync(string ip, int port)
        {
            var stopwatch = new Stopwatch();

            stopwatch.Start();
            var client = await tcpClientFactory.CreateTcpClient();

            Parallel.ForEach(await terminalService.Query <TerminalFilter>(), x => client.ConnectAsync(ip, port, x.Sim));
            return(Ok(new JsonResultDto <IEnumerable <ISession> >
            {
                Flag = true,
                Data = tcpClientManager.GetTcpClients().SelectMany(x => x.Sesions().Result),
                Message = $"耗时:{stopwatch.ElapsedMilliseconds}毫秒"
            }));
        }