Beispiel #1
0
void BattleScene::sendEnterBattle(){
    CSJson::FastWriter writer;
    CSJson::Value root;
    root["pid"]=GameData::shareGameData()->chaId;
    std::string str=writer.write(root);
    Message * msg= (Message *)socket->constructMessage(str, CMID_GETPERMITENTERBATTLE);
    socket->sendMessage_(msg, false);
    this->schedule(schedule_selector(BattleScene::receiveEnterBattle));
}
void MessageManager::sendBattleMesssage(){
    CSJson::FastWriter writer;
    CSJson::Value root;
    root["pid"]=GameData::shareGameData()->chaId;
    std::string json_str=writer.write(root);
    Message * msg=g_pSocket->constructMessage(json_str, CMID_GETAVAILABLEFB);
    CCNotificationCenter::sharedNotificationCenter()->addObserver(this, callfuncO_selector(MessageManager::receiveBattleMessage), "1201", NULL);
    g_pSocket->sendMessage_(msg, true);
    
}
Beispiel #3
0
void RemoteUser::Flush() {
  if (userid_.size() == 0)
    return;

  CSJson::FastWriter writer;
  CSJson::Value value;
  value["userid"] = userid_;
  std::string content = writer.write(value);
  CAWriteFile("userdata", (char *)content.c_str());
}
void MessageManager::sendPersonal(int chaId){
    CSJson::FastWriter writer;
    CSJson::Value writerJson;
    writerJson["pid"]=chaId;
    std::string json_str=writer.write(writerJson);
    Message *msg= (Message *)g_pSocket->constructMessage(json_str, CMID_TEAMINFO);
    CCNotificationCenter::sharedNotificationCenter()->addObserver(this, callfuncO_selector(MessageManager::receivePersonal), "1103", NULL);
    g_pSocket->sendMessage_(msg, true);
    
}
void  MessageManager::sendeGetWelfareMessage(int typeId){
    CSJson::FastWriter writer;
    CSJson::Value root;
    root["pid"]=GameData::shareGameData()->chaId;
    root["typeid"]=typeId;
    std::string jsonstr=writer.write(root);
    Message * msg= g_pSocket->constructMessage(jsonstr, CMID_GETWELFARE);
    CCNotificationCenter::sharedNotificationCenter()->addObserver(this, callfuncO_selector(MessageManager::receiveWelfareMessage), "1520", NULL);
    g_pSocket->sendMessage_(msg, false);
}
void MessageManager::sendPetMessage(){//获取上场宠物信息
    CSJson::FastWriter writer;
    CSJson::Value root;
    root["pid"]=GameData::shareGameData()->chaId;
    std::string json_str=writer.write(root);
    Message* msg= (Message *)g_pSocket->constructMessage(json_str, CMID_GETPETINFO);
    CCNotificationCenter::sharedNotificationCenter()->addObserver(this, callfuncO_selector(MessageManager::receivePetMessage), "1104", NULL);
    g_pSocket->sendMessage_(msg, false);
    
    
}
void MessageManager::sendStrengthenMessage(){
    CSJson::FastWriter writer;
    CSJson::Value root;
    root["pid"]=GameData::shareGameData()->chaId;
    std::string str= writer.write(root);
    Message * msg= g_pSocket->constructMessage(str, CMID_GETSTRENGTHENINFO);
    CCNotificationCenter::sharedNotificationCenter()->addObserver(this, callfuncO_selector(MessageManager::receiveStrengthenMessage), "1401", NULL);
    
    g_pSocket->sendMessage_(msg, false);
    
}
Beispiel #8
0
void shop::sendBuySkillMsg(int skillId){
    CSJson::FastWriter writer;
    CSJson::Value root;
    root["characterId"]=GameData::shareGameData()->charId;
    root["skill_id"]=skillId;
    std::string str=writer.write(root);
    Message * msg= (Message *)socket->constructMessage(str.c_str(), 802);

    socket->sendMessage_(msg, false);
    this->schedule(schedule_selector(shop::receiveBuySkillMsg));

}
void MessageManager::sendRegisterMessage(const char *uname,const char *pwd){
    CSJson::FastWriter writer;
    CSJson::Value root;
    root["uname"]=uname;
    root["pwd"]=pwd;
    std::string str= writer.write(root);
    Message * msg= g_pSocket->constructMessage(str.c_str(), CMID_REGISTER);
    CCNotificationCenter::sharedNotificationCenter()->addObserver(this, callfuncO_selector(MessageManager::receiveRegisterMessage), "1002", NULL);
    g_pSocket->sendMessage_(msg, true);
    
    
}
void MessageManager::sendLoginMessage(){
    std::string str;
    
    CSJson::FastWriter writer;
    CSJson::Value root;
    root["uname"]=CCUserDefault::sharedUserDefault()->getStringForKey("user").c_str();
    root["pwd"]=CCUserDefault::sharedUserDefault()->getStringForKey("password").c_str();
    str= writer.write(root);
    Message * msg= g_pSocket->constructMessage(str.c_str(), CMID_LOGIN);
    CCNotificationCenter::sharedNotificationCenter()->addObserver(this, callfuncO_selector(MessageManager::receiveLoginMessage), "1001", NULL);
    g_pSocket->sendMessage_(msg, true);
}
void MessageManager::sendStrenghtenInfoMessage(int pid,int petid,int typeids){
    CSJson::FastWriter writer;
    CSJson::Value root;
    root["pid"]=pid;
    root["petid"]=petid;
    root["typeid"]=typeids;
    std::string str=writer.write(root);
    CCLOG("%s",str.c_str());
    Message * msg= g_pSocket->constructMessage(str, CMID_STRENGTHPET);
    CCNotificationCenter::sharedNotificationCenter()->addObserver(this, callfuncO_selector(MessageManager::receiveStrengthenInfoMessage), "1402", NULL);
    g_pSocket->sendMessage_(msg, false);
    
}
Beispiel #12
0
void shop::sendloadSkill(int skillId,int space,int petId){
    CSJson::FastWriter writer;
    CSJson::Value root;
    root["characterId"]=GameData::shareGameData()->charId;
    root["skill_id"]=skillId;
    root["pet_id"]=GameData::shareGameData()->personId;
    root["space"]=space;
    std::string str=writer.write(root);
    Message * msg= (Message *)socket->constructMessage(str.c_str(), 805);
    CCLog("%s",str.c_str());
    socket->sendMessage_(msg, false);
    this->schedule(schedule_selector(shop::receiveloadSkill));
    
    
}
Beispiel #13
0
void LoginScene::sendLoginData()
{
    if(strlen(edtUserName->getText())==0 || strlen(edtPassword->getText())==0)
    {
        CCMessageBox(UiLanguage::shareLanguage()->get("login_check"), UiLanguage::shareLanguage()->get("msgbox_notice"));
        return;
    }
    CSJson::Value root;
    CSJson::FastWriter writer;
    root["username"] = edtUserName->getText();
    root["password"] = edtPassword->getText();
    std:string data = writer.write(root);
    Message* msg = new Message(data.c_str(), 1001);
    socket->sendMessage(msg);
    this->schedule(schedule_selector(LoginScene::recvLoginData));
}
void MainViewController::onRequestFinished(const HttpResponseStatus& status, const CSJson::Value& json)
{
    if (status == HttpResponseSucceed)
    {
        //CSJson::FastWriter writer;
        //string tempjson = writer.write(json);
        //CCLog("receive json == %s",tempjson.c_str());
        
        const CSJson::Value& value = json["result"];
        int length = value["bar"].size();
        m_msg->clear();
        m_filterMsg.clear();
        m_page.clear();
        m_pageAllMapVec.clear();
//        FDataManager::getInstance()->setDiffServerTime(value["stime"].asInt64());
        for (int i = 0; i < length; i++) {
            newsPage temp_page;
			//temp_page.m_type = value["bar"][i]["ResType"].asString();
			temp_page.m_imageUrl = crossapp_format_string("%s%s", imgPreUrl.c_str(), value["bar"][i]["Resource"].asCString());
            temp_page.m_lable = value["bar"][i]["ResLable"].asString();

            CCLog("m_imageUrl== %s",temp_page.m_imageUrl .c_str());
            //temp_page.m_titleId = value["bar"][i]["tid"].asInt();
            //temp_page.m_title = value["bar"][i]["til"].asString();
            m_pageAllMapVec.push_back(temp_page);
            //m_page.push_back(temp_page);
        }
        adjustPageViewContent();
        
//        initPageView();
        /*
//        if (m_pageView)
//        {
            int pageViewHeight = m_winSize.height * 0.3;
            int headerHeight = (120);
//            m_pageView = CAPageView::createWithFrame(DRect(0, headerHeight, m_winSize.width, pageViewHeight), CAPageViewDirectionHorizontal);
            if (m_pageView) {
                CAVector<CAView* > viewList;
                for (int i = 0; i<m_page.size(); i++)
                {
                    CommonUrlImageView* temImage = CommonUrlImageView::createWithFrame(DRect(0, (0), m_winSize.width, pageViewHeight - headerHeight));
                    temImage->setImageViewScaleType(CAImageViewScaleTypeFitImageCrop);
                    temImage->setImage(CAImage::create("common/bg.png"));
                    temImage->setUrl(m_page[i].m_imageUrl);
                    temImage->setTouchEnabled(false);
                    viewList.pushBack(temImage);
                }
                m_pageView->setViews(viewList);
                m_pageView->setCurrPage(0, false);
                if (m_pageControl) {
                    m_pageControl->setNumberOfPages((int)m_page.size());
                }
                
                // to : animate the page view
                CAScheduler::schedule(schedule_selector(MainViewController::updatePageView), this, 5);//, true, 3000);
            }
//        }
         */
        
        const CSJson::Value& v1 = json["result"]["sel"];
        length = v1.size();
        for (int index = 0; index < length; index++)
        {
            sessionMsg temp_msg;
            temp_msg.m_sessionId = v1[index]["SessionId"].asInt();
            temp_msg.m_title = v1[index]["Title"].asString();
            temp_msg.m_location = v1[index]["Location"].asString();
            temp_msg.m_track = v1[index]["Track"].asString();
            temp_msg.m_format = v1[index]["Format"].asString();
            temp_msg.m_startTime = v1[index]["StartTime"].asInt64();
			temp_msg.m_endTime = v1[index]["EndTime"].asInt64();
            temp_msg.m_likeNum = v1[index]["LikeCnt"].asInt();
            temp_msg.m_imageUrl = crossapp_format_string("%s%s", imgPreUrl.c_str(), v1[index]["Logo"].asCString());
            temp_msg.m_stored = v1[index]["CollectionFlag"].asBool();
			temp_msg.m_liked = v1[index]["LikeFlag"].asBool();
            temp_msg.m_done = v1[index]["Done"].asBool();
            temp_msg.m_point = v1[index]["Point"].asInt();
            m_msg->push_back(temp_msg);
        }
        
        const CSJson::Value& v2 = json["result"]["usr"];
        CSJson::FastWriter writer;
        string tempjson = writer.write(v2);
        CCLog("receive json == %s",tempjson.c_str());
        
        userInfo* uInfo = FDataManager::getInstance()->getUserInfo();
		uInfo->m_loginName = v2["LoginName"].asString();
        uInfo->m_userId = FDataManager::getInstance()->getUserId();
        uInfo->m_userName = crossapp_format_string("%s %s", v2["FirstName"].asString().c_str(), v2["LastName"].asString().c_str());
        uInfo->m_point = v2["Score"].asInt();
        uInfo->m_imageUrl = crossapp_format_string("%s%s", imgPreUrl.c_str(), v2["Icon"].asCString());
		uInfo->m_eggVoted = v2["EggVoted"].asBool();
        uInfo->m_greenAmb = v2["GreenAmb"].asBool();
		uInfo->m_demoVoteIdVec.clear();
		uInfo->m_voiceVoteIdVec.clear();
		int voteId = v2["DemoJamId1"].asInt();
		if (voteId != -1)
		{
			uInfo->m_demoVoteIdVec.push_back(voteId);
		}
		voteId = v2["DemoJamId2"].asInt();
		if (voteId != -1)
		{
			uInfo->m_demoVoteIdVec.push_back(voteId);
		}
		voteId = v2["VoiceVoteId1"].asInt();
		if (voteId != -1)
		{
			uInfo->m_voiceVoteIdVec.push_back(voteId);
		}
		voteId = v2["VoiceVoteId2"].asInt();
		if (voteId != -1)
		{
			uInfo->m_voiceVoteIdVec.push_back(voteId);
		}
        /*
        quickSort(m_msg, 0, (int)m_msg->size() - 1);
        m_filterMsg.clear();
        for (std::vector<sessionMsg>::iterator it = m_msg->begin(); it != m_msg->end(); it++)
        {
            if(it->m_stored && it->m_endTime > getTimeSecond())
            {
                m_filterMsg.push_back(&(*it));
            }
            if (m_filterMsg.size() == REFRESH_STEP)
            {
                break;
            }
        }
         */
        refreshTable();
    }
    else
    {
        //showAlert();
    }
    if (p_pLoading)
    {
        p_pLoading->stopAnimating();
    }
}
void SessionsViewController::onRequestFinished(const HttpResponseStatus& status, const CSJson::Value& json)
{
    if (status == HttpResponseSucceed && !json.empty())
    {
        CSJson::FastWriter writer;
        string tempjson = writer.write(json);
        //CCLog("receive json == %s",tempjson.c_str());
        
        const CSJson::Value& value = json["result"];
		FDataManager::getInstance()->setDiffServerTime(value["stime"].asInt64());

        m_msg->clear();
        m_msgFilter.clear();

		const CSJson::Value& v1 = json["result"]["sel"];
		int length = v1.size();
		for (int index = 0; index < length; index++)
		{
			sessionMsg temp_msg;
			temp_msg.m_sessionId = v1[index]["SessionId"].asInt();
			temp_msg.m_title = v1[index]["Title"].asString();
			temp_msg.m_location = v1[index]["Location"].asString();
			temp_msg.m_track = v1[index]["Track"].asString();
			temp_msg.m_format = v1[index]["Format"].asString();
			temp_msg.m_startTime = v1[index]["StartTime"].asInt64();
			temp_msg.m_endTime = v1[index]["EndTime"].asInt();
			temp_msg.m_likeNum = v1[index]["LikeCnt"].asInt();
			temp_msg.m_imageUrl = crossapp_format_string("%s%s", imgPreUrl.c_str(), v1[index]["Logo"].asCString());
			temp_msg.m_stored = v1[index]["CollectionFlag"].asBool();
			temp_msg.m_liked = v1[index]["LikeFlag"].asBool();
			temp_msg.m_done = v1[index]["Done"].asBool();
			temp_msg.m_point = v1[index]["Point"].asBool();
			m_msg->push_back(temp_msg);
		}
		const CSJson::Value& v2 = json["result"]["usr"];
        userInfo* uInfo = FDataManager::getInstance()->getUserInfo();
        uInfo->m_loginName = v2["LoginName"].asString();
        uInfo->m_userId = FDataManager::getInstance()->getUserId();
        uInfo->m_userName = crossapp_format_string("%s %s", v2["FirstName"].asString().c_str(), v2["LastName"].asString().c_str());
        uInfo->m_point = v2["Score"].asInt();
        uInfo->m_imageUrl = crossapp_format_string("%s%s", imgPreUrl.c_str(), v2["Icon"].asCString());
        uInfo->m_eggVoted = v2["EggVoted"].asBool();
        uInfo->m_greenAmb = v2["GreenAmb"].asBool();
        uInfo->m_demoVoteIdVec.clear();
        uInfo->m_voiceVoteIdVec.clear();
        int voteId = v2["DemoJamId1"].asInt();
        if (voteId != -1)
        {
            uInfo->m_demoVoteIdVec.push_back(voteId);
        }
        voteId = v2["DemoJamId2"].asInt();
        if (voteId != -1)
        {
            uInfo->m_demoVoteIdVec.push_back(voteId);
        }
        voteId = v2["VoiceVoteId1"].asInt();
        if (voteId != -1)
        {
            uInfo->m_voiceVoteIdVec.push_back(voteId);
        }
        voteId = v2["VoiceVoteId2"].asInt();
        if (voteId != -1)
        {
            uInfo->m_voiceVoteIdVec.push_back(voteId);
        }

        quickSort(m_msg, 0, (int)m_msg->size() - 1);
    }
	else
	{
		//showAlert();
	}
#ifdef LOCALTEST
    {
		m_msg->clear();

		for (int i = 0; i < 17; i++)
		{
			sessionMsg temp_msg;
			temp_msg.m_sessionId = 200 + i;
			temp_msg.m_title = "Customer Success";

			temp_msg.m_location = "Lisa Chen";
			temp_msg.m_track = "Customer";
			temp_msg.m_format = "Dev Faire";
			temp_msg.m_startTime = getTimeSecond();
			temp_msg.m_endTime = temp_msg.m_startTime + 3900;
			temp_msg.m_likeNum = 20;
			temp_msg.m_stored = (bool)(rand() % 2);
			temp_msg.m_imageUrl =
				"http://imgsrc.baidu.com/forum/pic/item/53834466d0160924a41f433bd50735fae6cd3452.jpg";
			//"http://img1.gtimg.com/14/1468/146894/14689486_980x1200_0.png";
			temp_msg.m_liked = (bool)(rand() % 2);
			temp_msg.m_done = (bool)(rand() % 2);
			temp_msg.m_point = 22;
			m_msg->push_back(temp_msg);

			userInfo uInfo;
			uInfo.m_userId = 101;
			uInfo.m_userName = "******";
			uInfo.m_point = 100;
			uInfo.m_pointRank = 20;
			uInfo.m_imageUrl = "http://imgsrc.baidu.com/forum/pic/item/53834466d0160924a41f433bd50735fae6cd3452.jpg";
			FDataManager::getInstance()->setUserInfo(uInfo);
		}
		quickSort(m_msg, 0, (int)m_msg->size() - 1);
    }
#endif

	refreshTableData();

    if (p_pLoading)
    {
        p_pLoading->stopAnimating();
    }
    
}