diff --git a/Libraries/Core/Servers/Http/SptHttpListener.cs b/Libraries/Core/Servers/Http/SptHttpListener.cs index a06b8bf4..1c1a6d76 100644 --- a/Libraries/Core/Servers/Http/SptHttpListener.cs +++ b/Libraries/Core/Servers/Http/SptHttpListener.cs @@ -130,14 +130,14 @@ public class SptHttpListener : IHttpListener } } - /** - * Send HTTP response back to sender - * @param sessionID Player id making request - * @param req Incoming request - * @param resp Outgoing response - * @param body Buffer - * @param output Server generated response data - */ + /// + /// Send HTTP response back to sender + /// + /// Player id making request + /// Incoming request + /// Outgoing response + /// Buffer + /// Server generated response data public void SendResponse( string sessionID, HttpRequest req, @@ -181,21 +181,21 @@ public class SptHttpListener : IHttpListener LogRequest(req, output); } - /** - * Is request flagged as debug enabled - * @param req Incoming request - * @returns True if request is flagged as debug - */ + /// + /// Is request flagged as debug enabled + /// + /// Incoming request + /// True if request is flagged as debug protected bool IsDebugRequest(HttpRequest req) { return req.Headers.TryGetValue("responsecompressed", out var value) && value == "0"; } - /** - * Log request if enabled - * @param req Incoming message request - * @param output Output string - */ + /// + /// Log request if enabled + /// + /// Log request if enabled + /// Output string protected void LogRequest(HttpRequest req, string output) { if (ProgramStatics.ENTRY_TYPE() != EntryType.RELEASE) diff --git a/Libraries/Core/Servers/HttpServer.cs b/Libraries/Core/Servers/HttpServer.cs index 23ef0cb5..6c13e120 100644 --- a/Libraries/Core/Servers/HttpServer.cs +++ b/Libraries/Core/Servers/HttpServer.cs @@ -26,6 +26,11 @@ public class HttpServer( private readonly HttpConfig _httpConfig = _configServer.GetConfig(); private bool _started; + /// + /// Handle server loading event + /// + /// Server builder + /// Throws Exception when WebApplicationBuiler or WebApplication are null public void Load(WebApplicationBuilder? builder) { if (builder is null) @@ -132,6 +137,11 @@ public class HttpServer( // This http request would be passed through the SPT Router and handled by an ICallback } + /// + /// Check against hardcoded values that determine it's from a local address + /// + /// Address to check + /// True if its local private bool? IsLocalRequest(string? remoteAddress) { if (remoteAddress == null) diff --git a/Libraries/Core/Servers/RagfairServer.cs b/Libraries/Core/Servers/RagfairServer.cs index 43120f8b..2f913268 100644 --- a/Libraries/Core/Servers/RagfairServer.cs +++ b/Libraries/Core/Servers/RagfairServer.cs @@ -66,10 +66,10 @@ public class RagfairServer( _ragfairRequiredItemsService.BuildRequiredItemTable(); } - /** - * Get traders who need to be periodically refreshed - * @returns string array of traders - */ + /// + /// Get traders who need to be periodically refreshed + /// + /// List of traders public List GetUpdateableTraders() { return _ragfairConfig.Traders.Keys.ToList(); @@ -84,10 +84,10 @@ public class RagfairServer( return _ragfairCategoriesService.GetCategoriesFromOffers(offers, searchRequestData, fleaUnlocked); } - /** - * Disable/Hide an offer from flea - * @param offerId - */ + /// + /// Disable/Hide an offer from flea + /// + /// OfferID to hide public void HideOffer(string offerId) { var offers = _ragfairOfferService.GetOffers(); diff --git a/Libraries/Core/Servers/SaveServer.cs b/Libraries/Core/Servers/SaveServer.cs index 6f503782..5cebd68d 100644 --- a/Libraries/Core/Servers/SaveServer.cs +++ b/Libraries/Core/Servers/SaveServer.cs @@ -32,20 +32,20 @@ public class SaveServer( protected ConcurrentDictionary profiles = new(); protected ConcurrentDictionary saveMd5 = new(); - /** - * Add callback to occur prior to saving profile changes - * @param id Id for save callback - * @param callback Callback to execute prior to running SaveServer.saveProfile() - */ + /// + /// Add callback to occur prior to saving profile changes + /// + /// ID for the save callback + /// Callback to execute prior to running SaveServer.saveProfile() public void AddBeforeSaveCallback(string id, Func callback) { onBeforeSaveCallbacks[id] = callback; } - /** - * Remove a callback from being executed prior to saving profile in SaveServer.saveProfile() - * @param id Id of callback to remove - */ + /// + /// Remove a callback from being executed prior to saving profile in SaveServer.saveProfile() + /// + /// ID of Callback to remove public void RemoveBeforeSaveCallback(string id) { if (onBeforeSaveCallbacks.ContainsKey(id)) @@ -54,9 +54,9 @@ public class SaveServer( } } - /** - * Load all profiles in /user/profiles folder into memory (this.profiles) - */ + /// + /// Load all profiles in /user/profiles folder into memory (this.profiles) + /// public void Load() { // get files to load @@ -81,9 +81,9 @@ public class SaveServer( } } - /** - * Save changes for each profile from memory into user/profiles json - */ + /// + /// Save changes for each profile from memory into user/profiles json + /// public void Save() { // Save every profile @@ -99,11 +99,12 @@ public class SaveServer( } } - /** - * Get a player profile from memory - * @param sessionId Session id - * @returns ISptProfile - */ + /// + /// Get a player profile from memory + /// + /// Session ID + /// SptProfile of the player + /// Thrown when sessionId is null / empty or no profiles with that ID are found public SptProfile GetProfile(string sessionId) { if (string.IsNullOrEmpty(sessionId)) @@ -129,20 +130,20 @@ public class SaveServer( return profiles.ContainsKey(id); } - /** - * Get all profiles from memory - * @returns Dictionary of ISptProfile - */ + /// + /// Gets all profiles from memory + /// + /// Dictionary of Profiles with their ID as Keys. public Dictionary GetProfiles() { return profiles.ToDictionary(); } - /** - * Delete a profile by id - * @param sessionID Id of profile to remove - * @returns true when deleted, false when profile not found - */ + /// + /// Delete a profile by id (Does not remove the profile file!) + /// + /// ID of profile to remove + /// True when deleted, false when profile not found public bool DeleteProfileById(string sessionID) { if (profiles.ContainsKey(sessionID)) @@ -156,10 +157,11 @@ public class SaveServer( return false; } - /** - * Create a new profile in memory with empty pmc/scav objects - * @param profileInfo Basic profile data - */ + /// + /// Create a new profile in memory with empty pmc/scav objects + /// + /// Basic profile data + /// Thrown when profile already exists public void CreateProfile(Info profileInfo) { if (profiles.ContainsKey(profileInfo.ProfileId)) @@ -181,20 +183,20 @@ public class SaveServer( ); } - /** - * Add full profile in memory by key (info.id) - * @param profileDetails Profile to save - */ + /// + /// Add full profile in memory by key (info.id) + /// + /// Profile to save public void AddProfile(SptProfile profileDetails) { profiles.TryAdd(profileDetails.ProfileInfo.ProfileId, profileDetails); } - /** - * Look up profile json in user/profiles by id and store in memory - * Execute saveLoadRouters callbacks after being loaded into memory - * @param sessionID Id of profile to store in memory - */ + /// + /// Look up profile json in user/profiles by id and store in memory.
+ /// Execute saveLoadRouters callbacks after being loaded into memory. + ///
+ /// ID of profile to store in memory public void LoadProfile(string sessionID) { var filename = $"{sessionID}.json"; @@ -213,12 +215,12 @@ public class SaveServer( } } - /** - * Save changes from in-memory profile to user/profiles json - * Execute onBeforeSaveCallbacks callbacks prior to being saved to json - * @param sessionID profile id (user/profiles/id.json) - * @returns time taken to save in MS - */ + /// + /// Save changes from in-memory profile to user/profiles json + /// Execute onBeforeSaveCallbacks callbacks prior to being saved to json + /// + /// Profile id (user/profiles/id.json) + /// Time taken to save the profile in seconds public long SaveProfile(string sessionID) { var filePath = $"{profileFilepath}{sessionID}.json"; @@ -261,11 +263,11 @@ public class SaveServer( return start.ElapsedMilliseconds; } - /** - * Remove a physical profile json from user/profiles - * @param sessionID Profile id to remove - * @returns true if file no longer exists - */ + /// + /// Remove a physical profile json from user/profiles + /// + /// Profile ID to remove + /// True if successful public bool RemoveProfile(string sessionID) { var file = $"{profileFilepath}{sessionID}.json";