/// <summary> /// 根据服务器客户端Id,从服务器查询客户端隧道信息 /// </summary> /// <param name="remoteClientId">服务器客户端Id</param> /// <returns>返回服务器客户端隧道信息</returns> private async Task <ChannelListOutput> GetRemoteChannelOutputAsync(int remoteClientId) { MiniProfiler.Current.Step("GetRemoteChannelOutputAsync"); var baseAuthInput = await BeforeRequestNpsApiAsync(); var searchApiResult = await _npsApi.ChannelListAsync(new ChannelListInput { AuthKey = baseAuthInput.AuthKey, Timestamp = baseAuthInput.Timestamp, ClientId = remoteClientId, KeyWords = "", Offset = "0", Limit = "100" }); return(searchApiResult ?? null); }
public async Task NpsClientChannelTest() { var authCpryKey = await _npsApi.AuthKeyAsync(); var serverTime = await _npsApi.ServerTimeAsync(); var authKey = Infrastructure.Helpers.EncryptHelper.Md5By32($"jyioself2020{serverTime.Timestamp}").ToLower(); var clientChannels = await _npsApi.ChannelListAsync(new Application.NpsApi.Dtos.ChannelListInput { AuthKey = authKey, Timestamp = serverTime.Timestamp, ClientId = 5, KeyWords = "",//10004可根据端口查询 Offset = "0", Limit = "10" }); serverTime = await _npsApi.ServerTimeAsync(); authKey = Infrastructure.Helpers.EncryptHelper.Md5By32($"jyioself2020{serverTime.Timestamp}").ToLower(); var clientChannel = await _npsApi.ChannelAsync(new Application.NpsApi.Dtos.ChannelIdInput { Id = 7, AuthKey = authKey, Timestamp = serverTime.Timestamp }); serverTime = await _npsApi.ServerTimeAsync(); authKey = Infrastructure.Helpers.EncryptHelper.Md5By32($"jyioself2020{serverTime.Timestamp}").ToLower(); var addClientChannel = await _npsApi.AddChannelAsync(new Application.NpsApi.Dtos.ChannelAddInput { AuthKey = authKey, Timestamp = serverTime.Timestamp, Remark = $"测试添加客户端隧道_{_serverPort++}", ServerPort = _serverPort, TargetAddress = "6677", ClientId = 9 }); serverTime = await _npsApi.ServerTimeAsync(); authKey = Infrastructure.Helpers.EncryptHelper.Md5By32($"jyioself2020{serverTime.Timestamp}").ToLower(); var editClientChannel = await _npsApi.EditChannelAsync(new Application.NpsApi.Dtos.ChannelEditInput { AuthKey = authKey, Timestamp = serverTime.Timestamp, Id = 7, Remark = $"测试编辑客户端隧道_{_serverPort++}", ServerPort = _serverPort, TargetAddress = "6677", ClientId = 9 }); serverTime = await _npsApi.ServerTimeAsync(); authKey = Infrastructure.Helpers.EncryptHelper.Md5By32($"jyioself2020{serverTime.Timestamp}").ToLower(); var startClientChannel = await _npsApi.StartChannelAsync(new Application.NpsApi.Dtos.ChannelIdInput { AuthKey = authKey, Timestamp = serverTime.Timestamp, Id = 7 }); serverTime = await _npsApi.ServerTimeAsync(); authKey = Infrastructure.Helpers.EncryptHelper.Md5By32($"jyioself2020{serverTime.Timestamp}").ToLower(); var stopClientChannel = await _npsApi.StopChannelAsync(new Application.NpsApi.Dtos.ChannelIdInput { AuthKey = authKey, Timestamp = serverTime.Timestamp, Id = 7 }); serverTime = await _npsApi.ServerTimeAsync(); authKey = Infrastructure.Helpers.EncryptHelper.Md5By32($"jyioself2020{serverTime.Timestamp}").ToLower(); var deleteClientChannel = await _npsApi.DeleteChannelAsync(new Application.NpsApi.Dtos.ChannelIdInput { AuthKey = authKey, Timestamp = serverTime.Timestamp, Id = 7 }); Assert.True(addClientChannel.Status == 1); Assert.True(editClientChannel.Status == 1); Assert.True(deleteClientChannel.Status == 1); }