mirror of
https://github.com/glest/glest-source.git
synced 2025-08-09 18:06:30 +02:00
Added some threading for URL calls for new masterserver game play
This commit is contained in:
@@ -53,6 +53,7 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu, b
|
|||||||
Config &config = Config::getInstance();
|
Config &config = Config::getInstance();
|
||||||
|
|
||||||
needToSetChangedGameSettings = false;
|
needToSetChangedGameSettings = false;
|
||||||
|
needToRepublishToMasterserver = false;
|
||||||
lastSetChangedGameSettings = time(NULL);
|
lastSetChangedGameSettings = time(NULL);
|
||||||
lastMasterserverPublishing = time(NULL);
|
lastMasterserverPublishing = time(NULL);
|
||||||
|
|
||||||
@@ -211,6 +212,15 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu, b
|
|||||||
|
|
||||||
//chatManager.init(&console, world.getThisTeamIndex());
|
//chatManager.init(&console, world.getThisTeamIndex());
|
||||||
chatManager.init(&console, -1);
|
chatManager.init(&console, -1);
|
||||||
|
|
||||||
|
publishToMasterserverThread = new SimpleTaskThread(this,0,100);
|
||||||
|
publishToMasterserverThread->start();
|
||||||
|
}
|
||||||
|
|
||||||
|
MenuStateCustomGame::~MenuStateCustomGame() {
|
||||||
|
BaseThread::shutdownAndWait(publishToMasterserverThread);
|
||||||
|
delete publishToMasterserverThread;
|
||||||
|
publishToMasterserverThread = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuStateCustomGame::mouseClick(int x, int y, MouseButton mouseButton){
|
void MenuStateCustomGame::mouseClick(int x, int y, MouseButton mouseButton){
|
||||||
@@ -223,6 +233,17 @@ void MenuStateCustomGame::mouseClick(int x, int y, MouseButton mouseButton){
|
|||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
soundRenderer.playFx(coreData.getClickSoundA());
|
soundRenderer.playFx(coreData.getClickSoundA());
|
||||||
|
|
||||||
|
/*
|
||||||
|
if( listBoxPublishServer.getEditable() &&
|
||||||
|
listBoxPublishServer.getSelectedItemIndex() == 0) {
|
||||||
|
needToRepublishToMasterserver = true;
|
||||||
|
lastMasterserverPublishing = 0;
|
||||||
|
publishToMasterserver();
|
||||||
|
simpleTask();
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
mainMenu->setState(new MenuStateNewGame(program, mainMenu));
|
mainMenu->setState(new MenuStateNewGame(program, mainMenu));
|
||||||
}
|
}
|
||||||
else if(buttonPlayNow.mouseClick(x,y) && buttonPlayNow.getEnabled()) {
|
else if(buttonPlayNow.mouseClick(x,y) && buttonPlayNow.getEnabled()) {
|
||||||
@@ -253,6 +274,14 @@ void MenuStateCustomGame::mouseClick(int x, int y, MouseButton mouseButton){
|
|||||||
bool bOkToStart = serverInterface->launchGame(&gameSettings);
|
bool bOkToStart = serverInterface->launchGame(&gameSettings);
|
||||||
if(bOkToStart == true)
|
if(bOkToStart == true)
|
||||||
{
|
{
|
||||||
|
if( listBoxPublishServer.getEditable() &&
|
||||||
|
listBoxPublishServer.getSelectedItemIndex() == 0) {
|
||||||
|
|
||||||
|
needToRepublishToMasterserver = true;
|
||||||
|
lastMasterserverPublishing = 0;
|
||||||
|
publishToMasterserver();
|
||||||
|
simpleTask();
|
||||||
|
}
|
||||||
program->setState(new Game(program, &gameSettings));
|
program->setState(new Game(program, &gameSettings));
|
||||||
}
|
}
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
@@ -264,38 +293,45 @@ void MenuStateCustomGame::mouseClick(int x, int y, MouseButton mouseButton){
|
|||||||
labelMapInfo.setText(mapInfo.desc);
|
labelMapInfo.setText(mapInfo.desc);
|
||||||
updateControlers();
|
updateControlers();
|
||||||
updateNetworkSlots();
|
updateNetworkSlots();
|
||||||
|
needToRepublishToMasterserver = true;
|
||||||
|
|
||||||
if(hasNetworkGameSettings() == true)
|
if(hasNetworkGameSettings() == true)
|
||||||
{
|
{
|
||||||
needToSetChangedGameSettings = true;
|
needToSetChangedGameSettings = true;
|
||||||
lastSetChangedGameSettings = time(NULL);;
|
lastSetChangedGameSettings = time(NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (listBoxFogOfWar.mouseClick(x, y)) {
|
else if (listBoxFogOfWar.mouseClick(x, y)) {
|
||||||
if(hasNetworkGameSettings() == true)
|
needToRepublishToMasterserver = true;
|
||||||
{
|
|
||||||
needToSetChangedGameSettings = true;
|
|
||||||
lastSetChangedGameSettings = time(NULL);;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(listBoxTileset.mouseClick(x, y)){
|
|
||||||
|
|
||||||
if(hasNetworkGameSettings() == true)
|
if(hasNetworkGameSettings() == true)
|
||||||
{
|
{
|
||||||
needToSetChangedGameSettings = true;
|
needToSetChangedGameSettings = true;
|
||||||
lastSetChangedGameSettings = time(NULL);;
|
lastSetChangedGameSettings = time(NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(listBoxTileset.mouseClick(x, y)){
|
||||||
|
needToRepublishToMasterserver = true;
|
||||||
|
|
||||||
|
if(hasNetworkGameSettings() == true)
|
||||||
|
{
|
||||||
|
needToSetChangedGameSettings = true;
|
||||||
|
lastSetChangedGameSettings = time(NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(listBoxTechTree.mouseClick(x, y)){
|
else if(listBoxTechTree.mouseClick(x, y)){
|
||||||
reloadFactions();
|
reloadFactions();
|
||||||
|
|
||||||
|
needToRepublishToMasterserver = true;
|
||||||
|
|
||||||
if(hasNetworkGameSettings() == true)
|
if(hasNetworkGameSettings() == true)
|
||||||
{
|
{
|
||||||
needToSetChangedGameSettings = true;
|
needToSetChangedGameSettings = true;
|
||||||
lastSetChangedGameSettings = time(NULL);;
|
lastSetChangedGameSettings = time(NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(listBoxPublishServer.mouseClick(x, y)&&listBoxPublishServer.getEditable()){
|
else if(listBoxPublishServer.mouseClick(x, y)&&listBoxPublishServer.getEditable()){
|
||||||
|
needToRepublishToMasterserver = true;
|
||||||
soundRenderer.playFx(coreData.getClickSoundC());
|
soundRenderer.playFx(coreData.getClickSoundC());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -331,6 +367,7 @@ void MenuStateCustomGame::mouseClick(int x, int y, MouseButton mouseButton){
|
|||||||
}
|
}
|
||||||
updateNetworkSlots();
|
updateNetworkSlots();
|
||||||
|
|
||||||
|
needToRepublishToMasterserver = true;
|
||||||
if(hasNetworkGameSettings() == true)
|
if(hasNetworkGameSettings() == true)
|
||||||
{
|
{
|
||||||
needToSetChangedGameSettings = true;
|
needToSetChangedGameSettings = true;
|
||||||
@@ -338,6 +375,7 @@ void MenuStateCustomGame::mouseClick(int x, int y, MouseButton mouseButton){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(listBoxFactions[i].mouseClick(x, y)){
|
else if(listBoxFactions[i].mouseClick(x, y)){
|
||||||
|
needToRepublishToMasterserver = true;
|
||||||
|
|
||||||
if(hasNetworkGameSettings() == true)
|
if(hasNetworkGameSettings() == true)
|
||||||
{
|
{
|
||||||
@@ -347,6 +385,8 @@ void MenuStateCustomGame::mouseClick(int x, int y, MouseButton mouseButton){
|
|||||||
}
|
}
|
||||||
else if(listBoxTeams[i].mouseClick(x, y))
|
else if(listBoxTeams[i].mouseClick(x, y))
|
||||||
{
|
{
|
||||||
|
needToRepublishToMasterserver = true;
|
||||||
|
|
||||||
if(hasNetworkGameSettings() == true)
|
if(hasNetworkGameSettings() == true)
|
||||||
{
|
{
|
||||||
needToSetChangedGameSettings = true;
|
needToSetChangedGameSettings = true;
|
||||||
@@ -606,15 +646,14 @@ void MenuStateCustomGame::update()
|
|||||||
listBoxPublishServer.setSelectedItemIndex(1);
|
listBoxPublishServer.setSelectedItemIndex(1);
|
||||||
listBoxPublishServer.setEditable(false);
|
listBoxPublishServer.setEditable(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(listBoxPublishServer.getEditable() && listBoxPublishServer.getSelectedItemIndex()==0 && (difftime(time(NULL),lastMasterserverPublishing) >= 15) ){
|
if(listBoxPublishServer.getEditable() &&
|
||||||
|
listBoxPublishServer.getSelectedItemIndex() == 0 &&
|
||||||
|
needToRepublishToMasterserver == true) {
|
||||||
// give it to me baby, aha aha ...
|
// give it to me baby, aha aha ...
|
||||||
lastMasterserverPublishing = time(NULL);
|
|
||||||
publishToMasterserver();
|
publishToMasterserver();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(difftime(time(NULL),lastSetChangedGameSettings) >= 2)
|
if(difftime(time(NULL),lastSetChangedGameSettings) >= 2)
|
||||||
{
|
{
|
||||||
GameSettings gameSettings;
|
GameSettings gameSettings;
|
||||||
@@ -651,14 +690,14 @@ void MenuStateCustomGame::publishToMasterserver()
|
|||||||
GameSettings gameSettings;
|
GameSettings gameSettings;
|
||||||
loadGameSettings(&gameSettings);
|
loadGameSettings(&gameSettings);
|
||||||
string serverinfo="";
|
string serverinfo="";
|
||||||
|
|
||||||
for(int i= 0; i<mapInfo.players; ++i)
|
for(int i= 0; i < mapInfo.players; ++i)
|
||||||
{
|
{
|
||||||
if(listBoxControls[i].getSelectedItemIndex() != ctClosed)
|
if(listBoxControls[i].getSelectedItemIndex() != ctClosed)
|
||||||
{
|
{
|
||||||
slotCountUsed++;
|
slotCountUsed++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(listBoxControls[i].getSelectedItemIndex() == ctNetwork)
|
if(listBoxControls[i].getSelectedItemIndex() == ctNetwork)
|
||||||
{
|
{
|
||||||
slotCountHumans++;
|
slotCountHumans++;
|
||||||
@@ -675,38 +714,36 @@ void MenuStateCustomGame::publishToMasterserver()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
//?status=waiting&system=linux&info=titus
|
//?status=waiting&system=linux&info=titus
|
||||||
serverinfo+="glestVersion="+escapeURL(glestVersionString)+"&";
|
serverinfo += "glestVersion=" + SystemFlags::escapeURL(glestVersionString) + "&";
|
||||||
serverinfo+="platform="+escapeURL(getPlatformNameString())+"&";
|
serverinfo += "platform=" + SystemFlags::escapeURL(getPlatformNameString()) + "&";
|
||||||
serverinfo+="binaryCompileDate="+escapeURL(getCompileDateTime())+"&";
|
serverinfo += "binaryCompileDate=" + SystemFlags::escapeURL(getCompileDateTime()) + "&";
|
||||||
|
|
||||||
//game info:
|
//game info:
|
||||||
serverinfo+="serverTitle="+escapeURL(Config::getInstance().getString("NetPlayerName")+"'s game")+"&";
|
serverinfo += "serverTitle=" + SystemFlags::escapeURL(Config::getInstance().getString("NetPlayerName") + "'s game") + "&";
|
||||||
//ip is automatically set
|
//ip is automatically set
|
||||||
|
|
||||||
//game setup info:
|
//game setup info:
|
||||||
serverinfo+="tech="+escapeURL(listBoxTechTree.getSelectedItem())+"&";
|
serverinfo += "tech=" + SystemFlags::escapeURL(listBoxTechTree.getSelectedItem()) + "&";
|
||||||
serverinfo+="map="+escapeURL(listBoxMap.getSelectedItem())+"&";
|
serverinfo += "map=" + SystemFlags::escapeURL(listBoxMap.getSelectedItem()) + "&";
|
||||||
serverinfo+="tileset="+escapeURL(listBoxTileset.getSelectedItem())+"&";
|
serverinfo += "tileset=" + SystemFlags::escapeURL(listBoxTileset.getSelectedItem()) + "&";
|
||||||
serverinfo+="activeSlots="+intToStr(slotCountUsed)+"&";
|
serverinfo += "activeSlots=" + intToStr(slotCountUsed) + "&";
|
||||||
serverinfo+="networkSlots="+intToStr(slotCountHumans)+"&";
|
serverinfo += "networkSlots=" + intToStr(slotCountHumans) + "&";
|
||||||
serverinfo+="connectedClients="+intToStr(slotCountConnectedPlayers);
|
serverinfo += "connectedClients=" + intToStr(slotCountConnectedPlayers);
|
||||||
|
|
||||||
string request = Config::getInstance().getString("Masterserver")+"addServerInfo.php?"+serverinfo;
|
publishToServerInfo = serverinfo;
|
||||||
printf("the request is:\n%s\n",request.c_str());
|
|
||||||
|
|
||||||
|
|
||||||
std::string serverInfo = SystemFlags::getHTTP(request);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
string MenuStateCustomGame::escapeURL(string in)
|
void MenuStateCustomGame::simpleTask() {
|
||||||
{
|
if( needToRepublishToMasterserver == true &&
|
||||||
char *escaped=curl_easy_escape(SystemFlags::curl_handle,in.c_str(),0);
|
difftime(time(NULL),lastMasterserverPublishing) >= 5) {
|
||||||
if(escaped==NULL)
|
|
||||||
abort();
|
needToRepublishToMasterserver = false;
|
||||||
string out=escaped;
|
lastMasterserverPublishing = time(NULL);
|
||||||
curl_free(escaped);
|
string request = Config::getInstance().getString("Masterserver") + "addServerInfo.php?" + publishToServerInfo;
|
||||||
return out;
|
printf("the request is:\n%s\n",request.c_str());
|
||||||
|
|
||||||
|
std::string serverInfo = SystemFlags::getHTTP(request);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuStateCustomGame::loadGameSettings(GameSettings *gameSettings)
|
void MenuStateCustomGame::loadGameSettings(GameSettings *gameSettings)
|
||||||
|
@@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
#include "main_menu.h"
|
#include "main_menu.h"
|
||||||
#include "chat_manager.h"
|
#include "chat_manager.h"
|
||||||
|
#include "simple_threads.h"
|
||||||
|
|
||||||
namespace Glest{ namespace Game{
|
namespace Glest{ namespace Game{
|
||||||
|
|
||||||
@@ -21,7 +22,7 @@ namespace Glest{ namespace Game{
|
|||||||
// class MenuStateCustomGame
|
// class MenuStateCustomGame
|
||||||
// ===============================
|
// ===============================
|
||||||
|
|
||||||
class MenuStateCustomGame: public MenuState{
|
class MenuStateCustomGame : public MenuState, public SimpleTaskCallbackInterface {
|
||||||
private:
|
private:
|
||||||
GraphicButton buttonReturn;
|
GraphicButton buttonReturn;
|
||||||
GraphicButton buttonPlayNow;
|
GraphicButton buttonPlayNow;
|
||||||
@@ -54,12 +55,16 @@ private:
|
|||||||
bool needToSetChangedGameSettings;
|
bool needToSetChangedGameSettings;
|
||||||
time_t lastSetChangedGameSettings;
|
time_t lastSetChangedGameSettings;
|
||||||
time_t lastMasterserverPublishing;
|
time_t lastMasterserverPublishing;
|
||||||
|
bool needToRepublishToMasterserver;
|
||||||
|
string publishToServerInfo;
|
||||||
|
SimpleTaskThread *publishToMasterserverThread;
|
||||||
|
|
||||||
Console console;
|
Console console;
|
||||||
ChatManager chatManager;
|
ChatManager chatManager;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MenuStateCustomGame(Program *program, MainMenu *mainMenu, bool openNetworkSlots= false);
|
MenuStateCustomGame(Program *program, MainMenu *mainMenu, bool openNetworkSlots= false);
|
||||||
|
~MenuStateCustomGame();
|
||||||
|
|
||||||
void mouseClick(int x, int y, MouseButton mouseButton);
|
void mouseClick(int x, int y, MouseButton mouseButton);
|
||||||
void mouseMove(int x, int y, const MouseState *mouseState);
|
void mouseMove(int x, int y, const MouseState *mouseState);
|
||||||
@@ -69,6 +74,8 @@ public:
|
|||||||
virtual void keyDown(char key);
|
virtual void keyDown(char key);
|
||||||
virtual void keyPress(char c);
|
virtual void keyPress(char c);
|
||||||
|
|
||||||
|
virtual void simpleTask();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
bool hasNetworkGameSettings();
|
bool hasNetworkGameSettings();
|
||||||
@@ -79,7 +86,6 @@ private:
|
|||||||
void closeUnusedSlots();
|
void closeUnusedSlots();
|
||||||
void updateNetworkSlots();
|
void updateNetworkSlots();
|
||||||
void publishToMasterserver();
|
void publishToMasterserver();
|
||||||
string escapeURL(string in);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}}//end namespace
|
}}//end namespace
|
||||||
|
@@ -142,7 +142,11 @@ MenuStateMasterserver::MenuStateMasterserver(Program *program, MainMenu *mainMen
|
|||||||
|
|
||||||
NetworkManager::getInstance().end();
|
NetworkManager::getInstance().end();
|
||||||
NetworkManager::getInstance().init(nrClient);
|
NetworkManager::getInstance().init(nrClient);
|
||||||
updateServerInfo();
|
//updateServerInfo();
|
||||||
|
|
||||||
|
needUpdateFromServer = true;
|
||||||
|
updateFromMasterserverThread = new SimpleTaskThread(this,0,100);
|
||||||
|
updateFromMasterserverThread->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
MenuStateMasterserver::~MenuStateMasterserver() {
|
MenuStateMasterserver::~MenuStateMasterserver() {
|
||||||
@@ -174,7 +178,8 @@ void MenuStateMasterserver::mouseClick(int x, int y, MouseButton mouseButton){
|
|||||||
}
|
}
|
||||||
else if(buttonRefresh.mouseClick(x, y)){
|
else if(buttonRefresh.mouseClick(x, y)){
|
||||||
soundRenderer.playFx(coreData.getClickSoundB());
|
soundRenderer.playFx(coreData.getClickSoundB());
|
||||||
updateServerInfo();
|
//updateServerInfo();
|
||||||
|
needUpdateFromServer = true;
|
||||||
}
|
}
|
||||||
else if(buttonReturn.mouseClick(x, y)){
|
else if(buttonReturn.mouseClick(x, y)){
|
||||||
soundRenderer.playFx(coreData.getClickSoundB());
|
soundRenderer.playFx(coreData.getClickSoundB());
|
||||||
@@ -222,7 +227,14 @@ void MenuStateMasterserver::render(){
|
|||||||
void MenuStateMasterserver::update(){
|
void MenuStateMasterserver::update(){
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MenuStateMasterserver::simpleTask() {
|
||||||
|
if(needUpdateFromServer == true) {
|
||||||
|
updateServerInfo();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void MenuStateMasterserver::updateServerInfo() {
|
void MenuStateMasterserver::updateServerInfo() {
|
||||||
|
needUpdateFromServer = false;
|
||||||
//MasterServerInfos masterServerInfos;
|
//MasterServerInfos masterServerInfos;
|
||||||
clearServerLines();
|
clearServerLines();
|
||||||
|
|
||||||
|
@@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
#include "main_menu.h"
|
#include "main_menu.h"
|
||||||
#include "masterserver_info.h"
|
#include "masterserver_info.h"
|
||||||
|
#include "simple_threads.h"
|
||||||
|
|
||||||
namespace Glest{ namespace Game{
|
namespace Glest{ namespace Game{
|
||||||
|
|
||||||
@@ -63,7 +64,7 @@ public:
|
|||||||
typedef vector<ServerLine*> ServerLines;
|
typedef vector<ServerLine*> ServerLines;
|
||||||
typedef vector<MasterServerInfo*> MasterServerInfos;
|
typedef vector<MasterServerInfo*> MasterServerInfos;
|
||||||
|
|
||||||
class MenuStateMasterserver: public MenuState{
|
class MenuStateMasterserver : public MenuState, public SimpleTaskCallbackInterface {
|
||||||
private:
|
private:
|
||||||
GraphicButton buttonRefresh;
|
GraphicButton buttonRefresh;
|
||||||
GraphicButton buttonReturn;
|
GraphicButton buttonReturn;
|
||||||
@@ -73,6 +74,8 @@ private:
|
|||||||
GraphicMessageBox mainMessageBox;
|
GraphicMessageBox mainMessageBox;
|
||||||
int mainMessageBoxState;
|
int mainMessageBoxState;
|
||||||
|
|
||||||
|
bool needUpdateFromServer;
|
||||||
|
SimpleTaskThread *updateFromMasterserverThread;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MenuStateMasterserver(Program *program, MainMenu *mainMenu);
|
MenuStateMasterserver(Program *program, MainMenu *mainMenu);
|
||||||
@@ -83,6 +86,8 @@ public:
|
|||||||
void update();
|
void update();
|
||||||
void render();
|
void render();
|
||||||
|
|
||||||
|
virtual void simpleTask();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void showMessageBox(const string &text, const string &header, bool toggle);
|
void showMessageBox(const string &text, const string &header, bool toggle);
|
||||||
void connectToServer(string ipString);
|
void connectToServer(string ipString);
|
||||||
|
@@ -348,11 +348,17 @@ void ConnectionSlot::update(bool checkForNewClients)
|
|||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
//throw runtime_error("Unexpected message in connection slot: " + intToStr(networkMessageType));
|
if(gotIntro == true) {
|
||||||
string sErr = "Unexpected message in connection slot: " + intToStr(networkMessageType);
|
//throw runtime_error("Unexpected message in connection slot: " + intToStr(networkMessageType));
|
||||||
//sendTextMessage(sErr,-1);
|
string sErr = "Unexpected message in connection slot: " + intToStr(networkMessageType);
|
||||||
DisplayErrorMessage(sErr);
|
//sendTextMessage(sErr,-1);
|
||||||
return;
|
DisplayErrorMessage(sErr);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] got invalid message type before intro, disconnecting socket.\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -115,6 +115,7 @@ public:
|
|||||||
static SystemFlagsType & getSystemSettingType(DebugType type) { return debugLogFileList[type]; }
|
static SystemFlagsType & getSystemSettingType(DebugType type) { return debugLogFileList[type]; }
|
||||||
static size_t httpWriteMemoryCallback(void *ptr, size_t size, size_t nmemb, void *data);
|
static size_t httpWriteMemoryCallback(void *ptr, size_t size, size_t nmemb, void *data);
|
||||||
static std::string getHTTP(std::string URL);
|
static std::string getHTTP(std::string URL);
|
||||||
|
static std::string escapeURL(std::string URL);
|
||||||
|
|
||||||
// Let the macro call into this when require.. NEVER call it automatically.
|
// Let the macro call into this when require.. NEVER call it automatically.
|
||||||
static void handleDebug(DebugType type, const char *fmt, ...);
|
static void handleDebug(DebugType type, const char *fmt, ...);
|
||||||
|
@@ -68,6 +68,18 @@ size_t SystemFlags::httpWriteMemoryCallback(void *ptr, size_t size, size_t nmemb
|
|||||||
return realsize;
|
return realsize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string SystemFlags::escapeURL(std::string URL)
|
||||||
|
{
|
||||||
|
string result = URL;
|
||||||
|
|
||||||
|
char *escaped=curl_easy_escape(SystemFlags::curl_handle,URL.c_str(),0);
|
||||||
|
if(escaped != NULL) {
|
||||||
|
result = escaped;
|
||||||
|
curl_free(escaped);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
std::string SystemFlags::getHTTP(std::string URL) {
|
std::string SystemFlags::getHTTP(std::string URL) {
|
||||||
curl_easy_setopt(SystemFlags::curl_handle, CURLOPT_URL, URL.c_str());
|
curl_easy_setopt(SystemFlags::curl_handle, CURLOPT_URL, URL.c_str());
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user