private void OnSocketError(IClient c, ClientErrorArgs e) { HttpApiServer httpApiServer = Server.Gateway.HttpServer; if (httpApiServer.EnableLog(BeetleX.EventArgs.LogType.Error)) { httpApiServer.Log(BeetleX.EventArgs.LogType.Error, $"gateway request {Server.Host}:{Server.Port} error {e.Message}@{e.Error.InnerException?.Message} status {Status}"); } if (Status == RequestStatus.Requesting) { EventResponseErrorArgs erea; if (e.Error is SocketException) { Code = Gateway.SERVER_SOCKET_ERROR; erea = new EventResponseErrorArgs(Request, Response, UrlRoute.Gateway, e.Error.Message, Gateway.SERVER_SOCKET_ERROR); } else { Code = Gateway.SERVER_PROCESS_ERROR_CODE; erea = new EventResponseErrorArgs(Request, Response, UrlRoute.Gateway, e.Error.Message, Gateway.SERVER_PROCESS_ERROR_CODE); } OnCompleted(erea); } else { Code = Gateway.SERVER_OTHRER_ERROR_CODE; if (Status > RequestStatus.None) { OnCompleted(null); } } }
public UserInfo GetUserInfo(HttpRequest request) { string token = request.Cookies[TOKEN_KEY]; if (string.IsNullOrEmpty(token)) { return(null); } try { return(GetUserInfo(token)); } catch (Exception e_) { HttpApiServer server = request.Server; if (server.EnableLog(LogType.Warring)) { server.Log(LogType.Warring, null, $"{request.RemoteIPAddress} get token error {e_.Message}"); } return(null); } }