void GameWin::syncFlow() { AppDelegate *app = (AppDelegate*)Application::getInstance(); std::string strFlow= updateFlow();//read local and add current NetworkType Networ = app->GetNetWorkStatus(); if (Networ != NetworkTypeNone) { if (m_UserID > 0 && strFlow.length()>0) { _UserInfo userInfo = DataAccess::getUserInfoByID(m_UserID); HttpRequest* request = new HttpRequest(); request->setUrl(UCAPIWebPostURL); request->setRequestType(HttpRequest::Type::POST); request->setResponseCallback(CC_CALLBACK_2(GameWin::onSyncCompleted, this)); //char p[10]; //sprintf(p, "%s", strFlow); std::string sPost = "action=save_user_info&EncryptData="; long lUserDiff = app->GetUserScoreDiff(); int iLevel = app->GetUserLevel(); char p1[10]; char p2[10]; char p3[10]; sprintf(p1, "%d", lUserDiff); sprintf(p2, "%d", iLevel); string s1 = p1; string s2 = p2; //std::string sPost = "action=sync_point&EncryptData="; int iTools = app->GetToolsDiff(); sprintf(p3, "%d", iTools); string s4 = p3; string s3 = "score = " + strFlow + "&local_point = " + s1 + "&LV = " + s2 + "&UserID = " + userInfo.strUserGuid+"&VirtualPops=" + s4; s3 = app->encode_data_for_http(s3); sPost = sPost + s3; sPost = sPost + "&" + app->GetAccessString(); const char* postData = sPost.c_str(); request->setRequestData(postData, strlen(postData)); request->setTag("save_ranking"); cocos2d::network::HttpClient::getInstance()->send(request); request->release(); } else updateLocalFlow();//not login or read local error } else { updateLocalFlow();//no network } }
void RegisterView::touchButton(Object* obj,::ui::Widget::TouchEventType eventType) { auto button = dynamic_cast<::ui::Button*>(obj); int tag = button->getTag(); if (eventType == ::ui::Widget::TouchEventType::ENDED) { if(tag==1001)//facebook { #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) iLoginType2=1; C2DXPlatType platType=C2DXPlatType::C2DXPlatTypeFacebook; C2DXShareSDK::getUserInfo(platType, reg_getUserResultHandler); #endif } if(tag==1002)//twitter { #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) iLoginType2=2; C2DXPlatType platType=C2DXPlatType::C2DXPlatTypeTwitter; C2DXShareSDK::getUserInfo(platType, reg_getUserResultHandler); #endif } if (tag == 2001)//Cancel,go back to chooselayer { /* auto scene = ChooseLayer::createScene(); TransitionScene *transition = TransitionFade::create(1, scene); Director::getInstance()->replaceScene(transition);*/ this->cleanup(); m_Refresh = 1; Director::getInstance()->popScene(); } if(tag==2002)//Do Register { auto textEMail = dynamic_cast<TextField*>(_rootNode->getChildByName("txtEMail")); auto textUserName = dynamic_cast<TextField*>(_rootNode->getChildByName("txtUserName")); auto textPassword=dynamic_cast<TextField*>(_rootNode->getChildByName("txtPassword")); auto textPasswordConfirm=dynamic_cast<TextField*>(_rootNode->getChildByName("txtConfPassword")); sPassword = textPassword->getString(); std::string sPasswordConf = textPasswordConfirm->getString(); if(sPassword==sPasswordConf) { std::string sEMail = textEMail->getString(); sUserName = textUserName->getString(); if (!CheckValid(sEMail)) { std::string title = "Input Error\0"; std::string msg = "Please input a valid E-Mail.\0"; ShowMsg(title, msg); } else { // Setting HTTP Request Header HttpRequest* request = new HttpRequest(); request->setUrl(UCAPIWebPostURL); request->setRequestType(HttpRequest::Type::POST); request->setResponseCallback(CC_CALLBACK_2(RegisterView::onHttpRequestCompleted, this)); // write the post data //std::string sPost = "action=register&username="******"&e_mail=" + sEMail + "&Password="******"action=register&EncryptData="; string s = "username = "******"&e_mail = " + sEMail + "&Password = "******"Register POST"); cocos2d::network::HttpClient::getInstance()->send(request); request->release(); } } else { std::string title = "Input Error\0"; std::string msg = "Password and Confirm Password Not Match.\0"; ShowMsg(title, msg); } } if(tag==2003)//go to login { auto scene = Login::createScene(); //TransitionScene *transition = TransitionFade::create(1, scene); //Director::getInstance()->replaceScene(transition); Director::getInstance()->pushScene(scene); } if (tag == 2101)//Terms { Application::getInstance()->openURL("https://tweebaa.com/College/Genernal_Terms_ofUse.aspx"); } if (tag == 2102)//Policy { Application::getInstance()->openURL("https://tweebaa.com/College/Privacy_Policy.aspx"); } } }