public ServerStateResponse GetServerState([FromBody] JsonFileVersionRequest request) { ServerStateResponse serverState = ServerStateResponse.Empty; if (request != null) { serverState = AppRoot.GetServerStateResponse(request.Key); if (request.ClientId != Guid.Empty) { var clientData = AppRoot.ClientDataSet.GetByClientId(request.ClientId); if (clientData != null && !string.IsNullOrEmpty(clientData.MACAddress)) { serverState.NeedReClientId = request.MACAddress.All(a => !clientData.MACAddress.Contains(a)); //NTMinerConsole.UserWarn($"重复的网卡地址:{string.Join(",", request.MACAddress)}"); } } } return(serverState); }
public void GetJsonFileVersionAsync(NTMinerAppType appType, string key, Action <ServerStateResponse> callback) { HashSet <string> macAddresses = new HashSet <string>(); foreach (var localIp in VirtualRoot.LocalIpSet.AsEnumerable().ToArray()) { macAddresses.Add(localIp.MACAddress); } JsonFileVersionRequest request = new JsonFileVersionRequest { Key = key, ClientId = NTMinerRegistry.GetClientId(appType), MACAddress = macAddresses.ToArray() }; RpcRoot.JsonRpc.PostAsync( RpcRoot.OfficialServerHost, RpcRoot.OfficialServerPort, _controllerName, nameof(IAppSettingController.GetServerState), request, callback: (ServerStateResponse response, Exception e) => { if (e != null) { Logger.ErrorDebugLine(e); } if (response == null) { response = ServerStateResponse.Empty; Logger.ErrorWriteLine("询问服务器状态失败,请检查网络。"); } if (response.NeedReClientId) { NTMinerRegistry.ReClientId(ClientAppType.AppType); RpcRoot.Client.NTMinerDaemonService.ReClientIdAsync(appType); Logger.InfoDebugLine("检测到本机标识存在重复,已重新生成"); } callback?.Invoke(response); }, timeountMilliseconds: 10 * 1000); }
public string GetJsonFileVersion([FromBody] JsonFileVersionRequest request) { return(GetServerState(request).ToLine()); }