void HomeScene::loginCallback(HttpClient * client, HttpResponse * response) { ChainHttpResponse wrappedResponse(response); rapidjson::Document d; d.Parse<0>(wrappedResponse.getDataString()); if (!d.HasParseError() && d.IsObject() && d.HasMember("result") && d.HasMember("info")) { if (d["result"].GetBool()) { UserDefault::getInstance()->setStringForKey("SID", wrappedResponse.getHeader("Set-Cookie")); auto gameScene = GameScene::createScene(); Director::getInstance()->pushScene(gameScene); } else { std::string notice("Login failed: "); notice.append(d["info"].GetString()); showNotice(notice.c_str()); } } else { showNotice("Bad response data"); } }
void NoticeManager::nextInQueue() { if(!queue.isEmpty() && list.size() < maxnotices) { QPair<QStringList,NoticeWindow::WindowType> newmessage = queue.first(); queue.removeFirst(); showNotice(newmessage.first.value(0),newmessage.first.value(1),newmessage.second); } }
void HomeScene::loginButtonClick(Ref * sender) { if (nameField->getString().size() == 0) { showNotice("Username required"); return; } std::string body("username="******"http://localhost:8080/login") ->setCharBufferContent(body.c_str()) ->POST(CC_CALLBACK_2(HomeScene::loginCallback, this)); }