string ValueJsonStringVisitor::visit(const cocos2d::Value &v) { switch (v.getType()) { case cocos2d::Value::Type::NONE: case cocos2d::Value::Type::BYTE: case cocos2d::Value::Type::INTEGER: case cocos2d::Value::Type::FLOAT: case cocos2d::Value::Type::DOUBLE: case cocos2d::Value::Type::BOOLEAN: return v.asString(); break; case cocos2d::Value::Type::STRING: return string("\"") + v.asString() + string("\""); break; case cocos2d::Value::Type::VECTOR: return visit(v.asValueVector()); break; case cocos2d::Value::Type::MAP: return visitMap<ValueMap>(v.asValueMap()); break; case cocos2d::Value::Type::INT_KEY_MAP: return visitMap<ValueMapIntKey>(v.asIntKeyMap()); break; default: CCASSERT(false, "Invalid type!"); break; } }
void U8SDKNativeCallback::OnU8InitSuc(cocos2d::Node *sender, cocos2d::Value data) { if (data.isNull() || data.getType() != cocos2d::Value::Type::MAP) { CCLOG("OnU8InitSuc Data Type Error:: curr data type is not map."); return; } cocos2d::ValueMap json = data.asValueMap(); bool exit = json["isSupportExit"].asBool(); bool accountCenter = json["isSupportAccountCenter"].asBool(); bool logout = json["isSupportLogout"].asBool(); U8SDKInterface::getInstance()->setSupports(exit, accountCenter, logout); if (this->gameCallback != nullptr) { this->gameCallback->OnInitSuc(); } }
void U8SDKNativeCallback::OnU8LoginSuc(cocos2d::Node *sender, cocos2d::Value data) { if (data.isNull() || data.getType() != cocos2d::Value::Type::MAP) { CCLOG("OnU8LoginSuc Data Type Error:: curr data type is not map."); return; } U8LoginResult* result = U8LoginResult::create(); cocos2d::ValueMap json = data.asValueMap(); result->isSuc = json["isSuc"].asBool(); result->isSwitchAccount = json["isSwitchAccount"].asBool(); result->userId = json["userID"].asString(); result->sdkUserId = json["sdkUserID"].asString(); result->username = json["username"].asString(); result->sdkUsername = json["sdkUsername"].asString(); result->token = json["token"].asString(); if (this->gameCallback != nullptr) { this->gameCallback->OnLoginSuc(result); } }