public ReportResponse ReportSpeed([FromBody] SpeedData speedData) { try { if (speedData == null) { return(ResponseBase.InvalidInput <ReportResponse>()); } ClientData clientData = HostRoot.Instance.ClientSet.GetByClientId(speedData.ClientId); if (clientData == null) { clientData = ClientData.Create(speedData, ClientIp); HostRoot.Instance.ClientSet.Add(clientData); } else { clientData.Update(speedData, ClientIp); } if (Version.TryParse(speedData.Version, out Version version)) { string jsonVersionKey = MainAssemblyInfo.GetServerJsonVersion(version); var response = ReportResponse.Ok(HostRoot.GetServerState(jsonVersionKey)); if (speedData.LocalServerMessageTimestamp.AddSeconds(1) < HostRoot.Instance.ServerMessageTimestamp) { var list = HostRoot.Instance.ServerMessageSet.GetServerMessages(speedData.LocalServerMessageTimestamp); if (list.Count < 10) { response.NewServerMessages.AddRange(list); } } return(response); } } catch (Exception e) { Logger.ErrorDebugLine(e); } return(ResponseBase.InvalidInput <ReportResponse>()); }
public ReportResponse ReportSpeed([FromBody] SpeedData speedData) { ReportResponse response; try { if (speedData == null) { response = ResponseBase.InvalidInput <ReportResponse>(); response.ServerState = ServerState.Empty; return(response); } ClientData clientData = HostRoot.Instance.ClientSet.GetByClientId(speedData.ClientId); if (clientData == null) { clientData = ClientData.Create(speedData, ClientIp); HostRoot.Instance.ClientSet.Add(clientData); } else { clientData.Update(speedData, ClientIp); } if (Version.TryParse(speedData.Version, out Version version)) { string jsonVersionKey = MainAssemblyInfo.GetServerJsonVersion(version); response = ResponseBase.Ok <ReportResponse>(); response.ServerState = HostRoot.GetServerState(jsonVersionKey); return(response); } } catch (Exception e) { Logger.ErrorDebugLine(e); } response = ResponseBase.InvalidInput <ReportResponse>(); response.ServerState = ServerState.Empty; return(response); }