Created
June 24, 2020 14:29
-
-
Save gmYusuf/e694c04076c77be23d596734984909d6 to your computer and use it in GitHub Desktop.
This file contains 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
#include "HelloWorldScene.h" | |
#include "SimpleAudioEngine.h" | |
#include "PluginHMS/PluginHMS.h" | |
#include "json/rapidjson.h" | |
#include "json/document.h" | |
..... | |
//Listener for HMS | |
class PluginHMSListener : public sdkbox::HMSListener { | |
public: | |
PluginHMSListener(HelloWorld* scene): hw(scene) { | |
} | |
void onLogin(int code, const std::string& errorOrJson) { | |
cocos2d::log("HMS onLogin: %d, %s", code, errorOrJson.c_str()); | |
if (0 != code) { | |
showMsg("login failed:" + errorOrJson); | |
return; | |
} | |
rapidjson::Document doc; | |
doc.Parse(errorOrJson.c_str()); | |
std::ostringstream ss; | |
ss << "Login success:" << doc["displayName"].GetString(); | |
showMsg(ss.str()); | |
} | |
private: | |
HelloWorld* hw; | |
}; | |
bool HelloWorld::init() | |
{ | |
sdkbox::PluginHMS::setListener(new PluginHMSListener(this)); | |
sdkbox::PluginHMS::buoyShow(); | |
...... | |
return true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment