/// <summary> /// Create a new CPO roaming. /// </summary> /// <param name="CPOClient">A CPO client.</param> /// <param name="CPOServer">A CPO sever.</param> public CPORoaming(CPOClient CPOClient, CPOServerAPI CPOServer) { this.CPOClient = CPOClient ?? throw new ArgumentNullException(nameof(CPOClient), "The given CPOClient must not be null!"); this.CPOServer = CPOServer ?? throw new ArgumentNullException(nameof(CPOServer), "The given CPOServer must not be null!"); // Link HTTP server events... CPOServer.RequestLog += (HTTPProcessor, ServerTimestamp, Request) => RequestLog.WhenAll(HTTPProcessor, ServerTimestamp, Request); CPOServer.ResponseLog += (HTTPProcessor, ServerTimestamp, Request, Response) => ResponseLog.WhenAll(HTTPProcessor, ServerTimestamp, Request, Response); CPOServer.ErrorLog += (HTTPProcessor, ServerTimestamp, Request, Response, Error, LastException) => ErrorLog.WhenAll(HTTPProcessor, ServerTimestamp, Request, Response, Error, LastException); }
/// <summary> /// Create a new CPO Server API logger using the default logging delegates. /// </summary> /// <param name="CPOServerAPI">An CPO Server API.</param> /// <param name="LoggingPath">The logging path.</param> /// <param name="Context">A context of this API.</param> /// <param name="LogFileCreator">A delegate to create a log file from the given context and log file name.</param> public Logger(CPOServerAPI CPOServerAPI, String LoggingPath, String Context = DefaultContext, LogfileCreatorDelegate LogFileCreator = null) : this(CPOServerAPI, LoggingPath, Context, null, null, null, null, LogFileCreator : LogFileCreator) { }
/// <summary> /// Create a new CPO Server API logger using the given logging delegates. /// </summary> /// <param name="CPOServerAPI">An CPO Server API.</param> /// <param name="LoggingPath">The logging path.</param> /// <param name="Context">A context of this API.</param> /// /// <param name="LogHTTPRequest_toConsole">A delegate to log incoming HTTP requests to console.</param> /// <param name="LogHTTPResponse_toConsole">A delegate to log HTTP requests/responses to console.</param> /// <param name="LogHTTPRequest_toDisc">A delegate to log incoming HTTP requests to disc.</param> /// <param name="LogHTTPResponse_toDisc">A delegate to log HTTP requests/responses to disc.</param> /// /// <param name="LogHTTPRequest_toNetwork">A delegate to log incoming HTTP requests to a network target.</param> /// <param name="LogHTTPResponse_toNetwork">A delegate to log HTTP requests/responses to a network target.</param> /// <param name="LogHTTPRequest_toHTTPSSE">A delegate to log incoming HTTP requests to a HTTP server sent events source.</param> /// <param name="LogHTTPResponse_toHTTPSSE">A delegate to log HTTP requests/responses to a HTTP server sent events source.</param> /// /// <param name="LogHTTPError_toConsole">A delegate to log HTTP errors to console.</param> /// <param name="LogHTTPError_toDisc">A delegate to log HTTP errors to disc.</param> /// <param name="LogHTTPError_toNetwork">A delegate to log HTTP errors to a network target.</param> /// <param name="LogHTTPError_toHTTPSSE">A delegate to log HTTP errors to a HTTP server sent events source.</param> /// /// <param name="LogFileCreator">A delegate to create a log file from the given context and log file name.</param> public Logger(CPOServerAPI CPOServerAPI, String LoggingPath, String Context, HTTPRequestLoggerDelegate LogHTTPRequest_toConsole, HTTPResponseLoggerDelegate LogHTTPResponse_toConsole, HTTPRequestLoggerDelegate LogHTTPRequest_toDisc, HTTPResponseLoggerDelegate LogHTTPResponse_toDisc, HTTPRequestLoggerDelegate LogHTTPRequest_toNetwork = null, HTTPResponseLoggerDelegate LogHTTPResponse_toNetwork = null, HTTPRequestLoggerDelegate LogHTTPRequest_toHTTPSSE = null, HTTPResponseLoggerDelegate LogHTTPResponse_toHTTPSSE = null, HTTPResponseLoggerDelegate LogHTTPError_toConsole = null, HTTPResponseLoggerDelegate LogHTTPError_toDisc = null, HTTPResponseLoggerDelegate LogHTTPError_toNetwork = null, HTTPResponseLoggerDelegate LogHTTPError_toHTTPSSE = null, LogfileCreatorDelegate LogFileCreator = null) : base(CPOServerAPI.HTTPServer, LoggingPath, Context, LogHTTPRequest_toConsole, LogHTTPResponse_toConsole, LogHTTPRequest_toDisc, LogHTTPResponse_toDisc, LogHTTPRequest_toNetwork, LogHTTPResponse_toNetwork, LogHTTPRequest_toHTTPSSE, LogHTTPResponse_toHTTPSSE, LogHTTPError_toConsole, LogHTTPError_toDisc, LogHTTPError_toNetwork, LogHTTPError_toHTTPSSE, LogFileCreator) { this.CPOServerAPI = CPOServerAPI ?? throw new ArgumentNullException(nameof(CPOServerAPI), "The given CPO Server API must not be null!"); #region AuthorizeRemoteReservationStart/-Stop RegisterEvent2("AuthorizeRemoteReservationStartRequest", handler => CPOServerAPI.OnAuthorizeRemoteReservationStartHTTPRequest += handler, handler => CPOServerAPI.OnAuthorizeRemoteReservationStartHTTPRequest -= handler, "AuthorizeRemoteReservationStart", "AuthorizeRemoteReservation", "requests", "all"). RegisterDefaultConsoleLogTarget(this). RegisterDefaultDiscLogTarget(this); RegisterEvent2("AuthorizeRemoteReservationStartResponse", handler => CPOServerAPI.OnAuthorizeRemoteReservationStartHTTPResponse += handler, handler => CPOServerAPI.OnAuthorizeRemoteReservationStartHTTPResponse -= handler, "AuthorizeRemoteReservationStart", "AuthorizeRemoteReservation", "reservations", "responses", "all"). RegisterDefaultConsoleLogTarget(this). RegisterDefaultDiscLogTarget(this); RegisterEvent2("AuthorizeRemoteReservationStopRequest", handler => CPOServerAPI.OnAuthorizeRemoteReservationStopHTTPRequest += handler, handler => CPOServerAPI.OnAuthorizeRemoteReservationStopHTTPRequest -= handler, "AuthorizeRemoteReservationStop", "AuthorizeRemoteReservation", "requests", "all"). RegisterDefaultConsoleLogTarget(this). RegisterDefaultDiscLogTarget(this); RegisterEvent2("AuthorizeRemoteReservationStopResponse", handler => CPOServerAPI.OnAuthorizeRemoteReservationStopHTTPResponse += handler, handler => CPOServerAPI.OnAuthorizeRemoteReservationStopHTTPResponse -= handler, "AuthorizeRemoteReservationStop", "AuthorizeRemoteReservation", "reservations", "responses", "all"). RegisterDefaultConsoleLogTarget(this). RegisterDefaultDiscLogTarget(this); #endregion #region AuthorizeRemoteStart/-Stop RegisterEvent2("AuthorizeRemoteStartRequest", handler => CPOServerAPI.OnAuthorizeRemoteStartHTTPRequest += handler, handler => CPOServerAPI.OnAuthorizeRemoteStartHTTPRequest -= handler, "AuthorizeRemoteStart", "AuthorizeRemote", "requests", "all"). RegisterDefaultConsoleLogTarget(this). RegisterDefaultDiscLogTarget(this); RegisterEvent2("AuthorizeRemoteStartResponse", handler => CPOServerAPI.OnAuthorizeRemoteStartHTTPResponse += handler, handler => CPOServerAPI.OnAuthorizeRemoteStartHTTPResponse -= handler, "AuthorizeRemoteStart", "AuthorizeRemote", "authorization", "responses", "all"). RegisterDefaultConsoleLogTarget(this). RegisterDefaultDiscLogTarget(this); RegisterEvent2("AuthorizeRemoteStopRequest", handler => CPOServerAPI.OnAuthorizeRemoteStopHTTPRequest += handler, handler => CPOServerAPI.OnAuthorizeRemoteStopHTTPRequest -= handler, "AuthorizeRemoteStop", "AuthorizeRemote", "requests", "all"). RegisterDefaultConsoleLogTarget(this). RegisterDefaultDiscLogTarget(this); RegisterEvent2("AuthorizeRemoteStopResponse", handler => CPOServerAPI.OnAuthorizeRemoteStopHTTPResponse += handler, handler => CPOServerAPI.OnAuthorizeRemoteStopHTTPResponse -= handler, "AuthorizeRemoteStop", "AuthorizeRemote", "authorization", "responses", "all"). RegisterDefaultConsoleLogTarget(this). RegisterDefaultDiscLogTarget(this); #endregion }