-
Notifications
You must be signed in to change notification settings - Fork 6
Add disconnect feature to api #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
abdulkadirozyurt
wants to merge
11
commits into
OpenIRL:main
Choose a base branch
from
abdulkadirozyurt:add-disconnect-feature-to-api
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 8 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
f78c78c
feat(docker): Add spdlog to runtime dependencies
abdulkadirozyurt 57b6292
feat(SLSManager): Add disconnect_publisher method to manage publisher…
abdulkadirozyurt f8e580a
feat(API): Add disconnect publisher endpoint and update documentation
abdulkadirozyurt cbd5b07
Delete test_disconnect_api.md
abdulkadirozyurt 982163f
SLSApiServer.cpp: Add publisher disconnect API endpoint
abdulkadirozyurt aa20947
SLSManager.hpp: Refactor disconnect and stats API to use publisher_id
abdulkadirozyurt c9070ec
SLSManager.cpp: Refactor disconnect logic to use publisher_id
abdulkadirozyurt 0767202
API.md: Update documentation for publisher_id-based disconnect endpoint
abdulkadirozyurt 342de7f
refactor(SLSManager): update disconnect logic to use publisher_key
abdulkadirozyurt 15154cb
Improve config parsing robustness: handle whitespace, comments, and l…
abdulkadirozyurt 5d44ad9
feat(SLSManager): enhance publisher disconnection logic
abdulkadirozyurt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| { | ||
| "workbench.colorTheme": "Visual Studio Dark" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -61,8 +61,8 @@ CSLSManager::CSLSManager() | |
| m_map_data = NULL; | ||
| m_map_publisher = NULL; | ||
| m_map_puller = NULL; | ||
| m_map_pusher = NULL; | ||
|
|
||
| m_map_pusher = NULL; | ||
| } | ||
|
|
||
| CSLSManager::~CSLSManager() | ||
|
|
@@ -195,62 +195,19 @@ int CSLSManager::start() | |
|
|
||
| } | ||
|
|
||
| char* CSLSManager::find_publisher_by_player_key(char *player_key) { | ||
| // First check stream ID database | ||
| std::string publisher_id = CSLSDatabase::getInstance().getPublisherFromPlayer(player_key); | ||
| if (!publisher_id.empty()) { | ||
| static thread_local char mapped_publisher[512]; | ||
| strncpy(mapped_publisher, publisher_id.c_str(), sizeof(mapped_publisher) - 1); | ||
| mapped_publisher[sizeof(mapped_publisher) - 1] = '\0'; | ||
|
|
||
| return mapped_publisher; | ||
| } | ||
|
|
||
| sls_log(SLS_LOG_WARNING, "[%p]CSLSManager::find_publisher_by_player_key, player key '%s' not found in database", | ||
| this, player_key); | ||
|
|
||
| // If not found in database, check if it's a direct publisher key | ||
| CSLSRole* role = nullptr; | ||
| for (int i = 0; i < m_server_count; i++) { | ||
| role = m_map_publisher[i].get_publisher(player_key); | ||
| if (role != nullptr) { | ||
| break; | ||
| } | ||
| } | ||
|
|
||
| if (role != NULL) { | ||
| sls_log(SLS_LOG_INFO, "[%p]CSLSManager::find_publisher_by_player_key, player key '%s' is a publisher key", | ||
| this, player_key); | ||
| return player_key; | ||
| } | ||
|
|
||
| sls_log(SLS_LOG_WARNING, "[%p]CSLSManager::find_publisher_by_player_key, no publisher found for player key '%s'", | ||
| this, player_key); | ||
| return NULL; | ||
| } | ||
|
|
||
| json CSLSManager::generate_json_for_publisher(std::string playerKey, int clear, bool legacy) { | ||
| // ...existing code... | ||
| json CSLSManager::generate_json_for_publisher(std::string publisher_id, int clear, bool legacy) { | ||
| json ret; | ||
| ret["status"] = "error"; | ||
|
|
||
| // Validate input | ||
| if (playerKey.empty()) { | ||
| ret["message"] = "Player key is required"; | ||
| sls_log(SLS_LOG_WARNING, "[%p]CSLSManager::generate_json_for_publisher, empty player key provided", this); | ||
| if (publisher_id.empty()) { | ||
| ret["message"] = "Publisher ID is required"; | ||
| sls_log(SLS_LOG_WARNING, "[%p]CSLSManager::generate_json_for_publisher, empty publisher_id provided", this); | ||
| return ret; | ||
| } | ||
|
|
||
| // Validate player key and get mapped publisher key | ||
| char* mapped_publisher = find_publisher_by_player_key(const_cast<char*>(playerKey.c_str())); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we need the player to receive our stats, so why have you deleted the code? |
||
| if (mapped_publisher == NULL) { | ||
| ret["message"] = "Invalid player key"; | ||
| sls_log(SLS_LOG_WARNING, "[%p]CSLSManager::generate_json_for_publisher, invalid player key: %s", | ||
| this, playerKey.c_str()); | ||
| return ret; | ||
| } | ||
|
|
||
| std::string publisher_key(mapped_publisher); | ||
|
|
||
| if (legacy) { | ||
| ret["publishers"] = json::object(); | ||
| } | ||
|
|
@@ -261,16 +218,16 @@ json CSLSManager::generate_json_for_publisher(std::string playerKey, int clear, | |
| CSLSRole *role = nullptr; | ||
| for (int i = 0; i < m_server_count; i++) { | ||
| CSLSMapPublisher *publisher_map = &m_map_publisher[i]; | ||
| role = publisher_map->get_publisher(publisher_key.c_str()); | ||
| role = publisher_map->get_publisher(publisher_id.c_str()); | ||
| if (role != nullptr) { | ||
| break; | ||
| } | ||
| } | ||
|
|
||
| if (role == nullptr) { | ||
| ret["message"] = "Publisher is currently not streaming"; | ||
| sls_log(SLS_LOG_DEBUG, "[%p]CSLSManager::generate_json_for_publisher, publisher not found: %s (mapped from player key: %s)", | ||
| this, publisher_key.c_str(), playerKey.c_str()); | ||
| sls_log(SLS_LOG_DEBUG, "[%p]CSLSManager::generate_json_for_publisher, publisher not found: %s", | ||
| this, publisher_id.c_str()); | ||
| return ret; | ||
| } | ||
|
|
||
|
|
@@ -282,12 +239,35 @@ json CSLSManager::generate_json_for_publisher(std::string playerKey, int clear, | |
| } | ||
| ret.erase("message"); | ||
|
|
||
| sls_log(SLS_LOG_DEBUG, "[%p]CSLSManager::generate_json_for_publisher, returning %s stats for publisher: %s (player key: %s)", | ||
| this, legacy ? "legacy" : "modern", publisher_key.c_str(), playerKey.c_str()); | ||
| sls_log(SLS_LOG_DEBUG, "[%p]CSLSManager::generate_json_for_publisher, returning %s stats for publisher: %s", | ||
| this, legacy ? "legacy" : "modern", publisher_id.c_str()); | ||
|
|
||
| return ret; | ||
| } | ||
|
|
||
| bool CSLSManager::disconnect_publisher(const std::string& player_key) { | ||
abdulkadirozyurt marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| // Search for the publisher in all server instances using publisher_id | ||
| CSLSRole *role = nullptr; | ||
| for (int i = 0; i < m_server_count; i++) { | ||
| CSLSMapPublisher *publisher_map = &m_map_publisher[i]; | ||
| role = publisher_map->get_publisher(player_key); // player_key artık publisher_id olarak kullanılıyor | ||
| if (role != nullptr) { | ||
| break; | ||
| } | ||
| } | ||
| if (role == nullptr) { | ||
| sls_log(SLS_LOG_WARNING, "[%p]CSLSManager::disconnect_publisher, publisher not found for publisher_id: %s", this, player_key.c_str()); | ||
| return false; | ||
| } | ||
| // Disconnect the publisher | ||
| sls_log(SLS_LOG_INFO, "[%p]CSLSManager::disconnect_publisher, disconnecting publisher: %s", this, player_key.c_str()); | ||
| // Call on_close to notify any HTTP callbacks | ||
| role->on_close(); | ||
| // Mark the role as invalid to trigger cleanup in the next cycle | ||
| role->invalid_srt(); | ||
| return true; | ||
| } | ||
|
|
||
| json CSLSManager::create_legacy_json_stats_for_publisher(CSLSRole *role, int clear) { | ||
| json ret = json::object(); | ||
| SRT_TRACEBSTATS stats; | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as in line 244: we need the player to receive our stats, so why have you deleted the code?