Skip to content
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

Fixed up json object and added lobbyPort for api response #953

Merged
merged 1 commit into from
May 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 17 additions & 13 deletions src/api/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,12 +244,14 @@ void createAccount( shared_ptr< HttpServer::Response > response, shared_ptr< Htt
std::string sId;
if( g_sapphireAPI.createAccount( user, pass, sId ) )
{
// todo: construct proper json object here
std::string json_string = "{\"sId\":\"" + sId +
"\", \"lobbyHost\":\"" +
m_config.global.network.lobbyHost +
"\", \"frontierHost\":\"" +
m_config.global.network.restHost + "\"}";
nlohmann::json response_json = {
{"sId", sId},
{"lobbyHost", m_config.global.network.lobbyHost},
{"frontierHost", m_config.global.network.restHost},
{"lobbyPort", m_config.global.network.lobbyPort}
};

std::string json_string = response_json.dump();
*response << buildHttpResponse( 200, json_string, JSON );
}
else
Expand Down Expand Up @@ -277,12 +279,15 @@ void login( shared_ptr< HttpServer::Response > response, shared_ptr< HttpServer:
// reloadConfig();
if( g_sapphireAPI.login( user, pass, sId ) )
{
// todo: build proper json object and stringify it
std::string json_string = "{\"sId\":\"" + sId +
"\", \"lobbyHost\":\"" +
m_config.global.network.lobbyHost +
"\", \"frontierHost\":\"" +
m_config.global.network.restHost + "\"}";
nlohmann::json response_json = {
{"sId", sId},
{"lobbyHost", m_config.global.network.lobbyHost},
{"frontierHost", m_config.global.network.restHost},
{"lobbyPort", m_config.global.network.lobbyPort}
};

std::string json_string = response_json.dump();

*response << buildHttpResponse( 200, json_string, JSON );
}
else
Expand All @@ -294,7 +299,6 @@ void login( shared_ptr< HttpServer::Response > response, shared_ptr< HttpServer:
*response << buildHttpResponse( 500 );
Logger::error( e.what() );
}

}

void deleteCharacter( shared_ptr< HttpServer::Response > response, shared_ptr< HttpServer::Request > request )
Expand Down
Loading