Added server-version configuration, which supports the GSOC server (version 2).

Made version 1 compatible with the 0.8.1 stkaddon server (i.e. all commands
are sent to client-user.php, and receive the actual command as 'action' parameter).
This commit is contained in:
hiker 2014-08-11 14:10:01 +10:00
parent 940a296366
commit 93fcb9a2a7
2 changed files with 26 additions and 8 deletions

View File

@ -694,6 +694,12 @@ namespace UserConfigParams
&m_online_group,
"The server used for online multiplayer."));
PARAM_PREFIX IntUserConfigParam m_server_version
PARAM_DEFAULT( IntUserConfigParam( 1,
"server-version",
&m_online_group,
"Version of the server API to use."));
// ---- Addon server related entries
PARAM_PREFIX GroupUserConfigParam m_addon_group
PARAM_DEFAULT( GroupUserConfigParam("AddonAndNews",

View File

@ -99,18 +99,30 @@ namespace Online
// ------------------------------------------------------------------------
/** A handy shortcut that appends the given path to the URL of the
* mutiplayer server.
* mutiplayer server. It also supports the old (version 1) api,
* where a 'action' parameter was sent to 'client-user.php'.
* \param path The path to add to the server.(see API::USER_*)
* \param action The action to perform. eg: connect, pool
*/
void HTTPRequest::setApiURL(const std::string& path, const std::string &action)
void HTTPRequest::setApiURL(const std::string& path,
const std::string &action)
{
setURL(
(std::string)UserConfigParams::m_server_multiplayer +
API::VERSION + "/" + // eg: v1, v2, etc
path + // eg: user/, server/
action + "/" // eg: connect/, pool/, get-server-list/
);
// Old (0.8.1) API: send to client-user.php, and add action as a parameter
if(UserConfigParams::m_server_version==1)
{
setURL( (std::string)UserConfigParams::m_server_multiplayer +
"client-user.php" );
addParameter("action", action);
}
else
{
setURL(
(std::string)UserConfigParams::m_server_multiplayer +
API::VERSION + "/" + // eg: v1, v2, etc
path + // eg: user/, server/
action + "/" // eg: connect/, pool/, get-server-list/
);
}
} // setServerURL
// ------------------------------------------------------------------------