示例#1
0
void RecordSystem::PurchaseRecord(int32_t purchase_page, const Store::ShopProduct * product, int32_t shopType, int32_t purchase_retCode, int32_t user_action, int32_t argu1)
{
    if ( m_ServerRecordType & Log::PurchaseRecord)
    {
        Json::Value content;
        JsonStream jstream(content);
        jstream.push("purchase_page", purchase_page);
        jstream.push("purchase_retCode", purchase_retCode);
        jstream.push("user_action", user_action);
        jstream.push("arg1", argu1);
        
        if (product!=NULL)
        {
            jstream.push("pid", product->pid);
            jstream.push("productType", product->type);
            jstream.push("productCount", product->quantity);
            jstream.push("price", product->price);
            jstream.push("vipPoints", product->vipPoints);
        }
        
        jstream.push("discountType", shopType);
        
        jstream.push("cur_coin", PlayerMan::getInstance().getCurChips());
        jstream.push("cur_gem", PlayerMan::getInstance().getCurGold());
        jstream.push("cur_level", PlayerMan::getInstance().getPlayerDetail().level);
        jstream.push("cur_vipLevel", PlayerMan::getInstance().getVipLevel());

        Log::getInstance()->output2Server(Log::PurchaseRecord, content);
    }
}
示例#2
0
void RecordSystem::GameStatusRecord(int32_t action)
{
    Json::Value content;
    JsonStream jstream(content);
    jstream.push("action", action);
    time_t now;
    time(&now);
    if (action == RecordSystem_UserAction_Enter)
    {
        m_WholeGameRunningTime = now;
        jstream.push("begin_time", m_WholeGameRunningTime);
        jstream.push("c_time", 0);
        jstream.push("spinTotal", 0);
    }
    if (action == RecordSystem_UserAction_Quit)
    {
        jstream.push("begin_time", m_WholeGameRunningTime);
        jstream.push("c_time", now - m_WholeGameRunningTime);
        jstream.push("spinTotal", PlayerMan::getInstance().getSlotsSpinTotal());
        m_WholeGameRunningTime = now;
    }
    
    if (PlayerMan::getInstance().getChangeTime() != 0 && action == RecordSystem_UserAction_Quit)
    {
        PlayerMan::getInstance().leaveGameRoom();
        GameRecord(PlayerMan::getInstance().getGameType(), RecordSystem_UserAction_Quit, static_cast<int32_t>(PlayerMan::getInstance().getGameRoomId()), PlayerMan::getInstance().getGameSujectId(), 0, 0, 0, 0);
        PlayerMan::getInstance().enterGameRoom();
    }
    
    Log::getInstance()->output2Server(Log::GameStatus, content);
}
示例#3
0
void RecordSystem::BonusRecord(int32_t bonus_page, int32_t user_action, int64_t ret, int64_t argu1)
{
    if ( m_ServerRecordType & Log::Bonus)
    {
        Json::Value content;
        JsonStream jstream(content);
        jstream.push("bonus_page", bonus_page);
        jstream.push("user_action", user_action);
        jstream.push("ret", ret);
        jstream.push("arg1", argu1);
        jstream.push("cur_coin", PlayerMan::getInstance().getCurChips());
        jstream.push("cur_gem", PlayerMan::getInstance().getCurGold());
        jstream.push("cur_level", PlayerMan::getInstance().getPlayerDetail().level);
        
        if (user_action == RecordSystem_UserAction_Enter)
        {
            time(&m_BonusRecord_time);
            jstream.push("c_time", 0);
        }
        else if(user_action == RecordSystem_UserAction_Quit)
        {
            time_t now;
            time(&now);
            jstream.push("c_time", difftime(now, m_BonusRecord_time));
            m_BonusRecord_time = 0;
        }
        
        Log::getInstance()->output2Server(Log::Bonus, content);
    }
}
示例#4
0
void RecordSystem::SlotRecord(const Social::SlotRecord & record)
{
    Json::Value content;
    JsonStream jstream(content);
    jstream.push("spin", record.spin);
    jstream.push("maxWin", record.maxWin);
    jstream.push("totalWin", record.totalWin);
    jstream.push("wins", record.wins);
    
    Log::getInstance()->output2Server(Log::SlotRecord, content);
}
示例#5
0
void RecordSystem::FaceBookRecord(int32_t action, const char * message, const char * returnmsg, int64_t argu1)
{
    if ( m_ServerRecordType & Log::FaceBookRecord)
    {
        Json::Value content;
        JsonStream jstream(content);
        jstream.push("action", action);
        jstream.push("message", std::string(message));
        jstream.push("returnmsg", std::string(returnmsg));
        jstream.push("arg1", argu1);
        Log::getInstance()->output2Server(Log::FaceBookRecord, content);
    }
}
示例#6
0
void RecordSystem::ErrorRecord(const char * errormessage, int64_t errorCode, const char *file , int line)
{
    if ( m_ServerRecordType & Log::ErrorMessage)
    {
        Json::Value content;
        JsonStream jstream(content);
        jstream.push("errormessage", std::string(errormessage));
        jstream.push("errorCode", errorCode);
        jstream.push("file", std::string(file));
        jstream.push("line", line);
        Log::getInstance()->output2Server(Log::ErrorMessage, content);
    }
}
示例#7
0
void RecordSystem::ResFileDownloadRecord(int32_t action, const std::string & dir, uint64_t downlaod_time, int32_t progress, int32_t error)
{
    if ( m_ServerRecordType & Log::ResFileDownloadRecord)
    {
        Json::Value content;
        JsonStream jstream(content);
        jstream.push("action", action);
        jstream.push("dir", dir);
        jstream.push("downlaod_time", downlaod_time);
        jstream.push("progress", progress );
        jstream.push("error", error);
        
        Log::getInstance()->output2Server(Log::ResFileDownloadRecord, content);
    }
}
示例#8
0
void RecordSystem::LoginRecord(int32_t login_page, int32_t loginResult, int32_t loginType, int32_t user_action, const std::string & FBID, int64_t argu1)
{
    if ( m_ServerRecordType & Log::LoginRecord)
    {
        Json::Value content;
        JsonStream jstream(content);
        jstream.push("login_page", login_page);
        jstream.push("loginResult", loginResult);
        jstream.push("loginType", loginType);
        jstream.push("user_action", user_action);
        jstream.push("FBID", FBID);
        jstream.push("arg1", argu1);
        jstream.push("platform", Utils::getTargetPlatform());
        
        Log::getInstance()->output2Server(Log::LoginRecord, content);
    }
}
示例#9
0
void RecordSystem::UserProductRecord(int32_t reason, int64_t cGem, int64_t cCoin, int32_t cLevel, int64_t arg1)
{
    if ( m_ServerRecordType & Log::UserProductRecord)
    {
        Json::Value content;
        JsonStream jstream(content);
        jstream.push("reason", reason);
        jstream.push("c_gem", cGem);
        jstream.push("c_coin", cCoin);
        jstream.push("c_level", cLevel>0?(cLevel - PlayerMan::getInstance().getPlayerDetail().level):0 );
        jstream.push("arg1", arg1);
        jstream.push("cur_coin", PlayerMan::getInstance().getCurChips() + cCoin);
        jstream.push("cur_gem", PlayerMan::getInstance().getCurGold() + cGem);
        jstream.push("cur_level", cLevel>0?cLevel:PlayerMan::getInstance().getPlayerDetail().level);
        
        Log::getInstance()->output2Server(Log::UserProductRecord, content);
    }
}
示例#10
0
void Log::output2Server(Log::Group group, Json::Value & arguments)
{
    JsonStream jstream(arguments);
    jstream.push("UDID", Utils::getUDID());
    jstream.push("PID", PlayerMan::getInstance().getPlayerId());
    jstream.push("PT", Utils::getTargetPlatform());
    jstream.push("V", (unsigned int)(Utils::getClientVersion()));
    jstream.push("IAP", PlayerMan::getInstance().getPlayerDetail().iapTotal);
    
    Json::Value root;
    JsonStream jrootstream(root);
    jrootstream.push("type", std::string(getGroupString(group)));
    jrootstream.push("value", arguments);
    
    ScopedMutex _locker(m_mutexBuffer);
    m_networkBufList.push_back(root);
    return;
}
示例#11
0
void Log::flushToServer( )
{
    m_countdown = 0;

    WorkerThreads::getInstance()->runOnThread(WorkerThreads::HttpServer, [this](float)
    {
        
        std::string logContent;
        Json::Value jarray;
        ScopedMutex _locker(m_mutexBuffer);
        if (m_networkBufList.size() > 0)
        {
            int arrayINdex = 0;
            for (auto itr = m_networkBufList.begin(); itr != m_networkBufList.end(); ++itr)
            {
                jarray[arrayINdex++] = *itr;
                //            free(*itr);
            }
        }
        else
        {
            return;
        }
        
        m_networkBufList.clear();
        
        Json::Value jcontent;
        JsonStream jstream(jcontent);
        jstream.push("projName", std::string("LuckyCasino"));
        jstream.push("actions", jarray);
        
        Json::Value jsend;
        JsonStream jsendstream(jsend);
        jsendstream.push("content", jcontent);
        logContent = jsend.toStyledString();
        
        Headers headers;
        headers["Content-Type"] = "application/json";
        headers["charset"] = "utf-8";
        std::shared_ptr<Request> request(Request::create(POST, HTTPS_LOG_API_URL, logContent, headers, WorkerThreads::HttpServer, Request::HttpAny, Request::DefaultRetry, [](const Request* request, Response* response, bool isFinish) {}));
        HttpClient::getHttpClientInstance()->get(request);
        
    });
}
示例#12
0
void RecordSystem::SocialRecord(int32_t cur_page, int32_t user_action, int64_t playerId, int64_t argu1, int64_t argu2)
{
    if ( m_ServerRecordType & Log::Social)
    {
        Json::Value content;
        JsonStream jstream(content);
        jstream.push("cur_page", cur_page);
        jstream.push("user_action", user_action);
        jstream.push("playerId", playerId);
        jstream.push("arg1", argu1);
        jstream.push("arg2", argu2);
        jstream.push("cur_coin", PlayerMan::getInstance().getCurChips());
        jstream.push("cur_gem", PlayerMan::getInstance().getCurGold());
        jstream.push("cur_level", PlayerMan::getInstance().getPlayerDetail().level);    
        jstream.push("cur_vipLevel", PlayerMan::getInstance().getVipLevel());
        
        Log::getInstance()->output2Server(Log::Social, content);
    }
}
示例#13
0
void RecordSystem::PlayerRecord(const Social::Profile & profile)
{
    Json::Value content;
    JsonStream jstream(content);
    jstream.push("id", profile._id);
    jstream.push("gender", profile.gender);
    jstream.push("location", profile.hometown);
    jstream.push("nickname", profile.name);
    jstream.push("facebookId", profile.fbId);
    jstream.push("level", profile.level);
    jstream.push("exp", profile.exp);
    jstream.push("gold", profile.gems);
    jstream.push("chips", profile.coins);
    jstream.push("vipLevel", profile.vipLevel);
    jstream.push("vipPoints", profile.vipPoints);
    jstream.push("purchaseCount", PlayerMan::getInstance().getPlayerDetail().purchaseCount);
    jstream.push("iapTotal", PlayerMan::getInstance().getPlayerDetail().iapTotal);

    Log::getInstance()->output2Server(Log::PlayerRecord, content);
}
extern "C" jlong Java_java_util_zip_Inflater_createStream(JNIEnv* env, jobject, jboolean noHeader) {
    UniquePtr<NativeZipStream> jstream(new NativeZipStream);
    if (jstream.get() == NULL) {
        jniThrowOutOfMemoryError(env, NULL);
        return -1;
    }
    jstream->stream.adler = 1;

    /*
     * See zlib.h for documentation of the inflateInit2 windowBits parameter.
     *
     * zconf.h says the "requirements for inflate are (in bytes) 1 << windowBits
     * that is, 32K for windowBits=15 (default value) plus a few kilobytes
     * for small objects." This means that we can happily use the default
     * here without worrying about memory consumption.
     */
    int err = inflateInit2(&jstream->stream, noHeader ? -DEF_WBITS : DEF_WBITS);
    if (err != Z_OK) {
        throwExceptionForZlibError(env, "java/lang/IllegalArgumentException", err, jstream.get());
        return -1;
    }
    return reinterpret_cast<uintptr_t>(jstream.release());
}
示例#15
0
void RecordSystem::GameRecord(int32_t cur_game, int32_t user_action, int32_t roomId, int32_t subjectId, int32_t seatId, int playerNumber, int32_t ret, int64_t argu1)
{
    if ( m_ServerRecordType & Log::GameRecord)
    {
        Json::Value content;
        JsonStream jstream(content);
        jstream.push("cur_game", cur_game);
        jstream.push("user_action", user_action);
        jstream.push("roomId", roomId);
        jstream.push("subjectId", subjectId);
        jstream.push("seatId", seatId);
        jstream.push("playerNumber", playerNumber);
        jstream.push("ret", ret);
        jstream.push("arg1", argu1);

        jstream.push("cur_coin", PlayerMan::getInstance().getCurChips());
        jstream.push("cur_gem", PlayerMan::getInstance().getCurGold());
        jstream.push("cur_level", PlayerMan::getInstance().getPlayerDetail().level);
        jstream.push("cur_vipLevel", PlayerMan::getInstance().getVipLevel());
        if (roomId == 0 || subjectId == 0)
        {
            jstream.push("c_coin", 0 );
            jstream.push("c_gem", 0);
            jstream.push("c_level", 0);
            jstream.push("c_round", 0);
            jstream.push("avg_bets", 0);
            time_t now;
            time(&now);
            if (user_action == RecordSystem_UserAction_Enter)
            {
                jstream.push("c_time", 0);
                m_LobbyRunningTime = now;
            }
            else if(user_action == RecordSystem_UserAction_Quit)
            {
                m_LobbyRunningTime = now - m_LobbyRunningTime;
                jstream.push("c_time", m_LobbyRunningTime);
                m_LobbyRunningTime = 0;
            }
        }
        else
        {
            if (user_action == RecordSystem_UserAction_Enter)
            {
                jstream.push("c_coin", 0 );
                jstream.push("c_gem", 0);
                jstream.push("c_level", 0);
                jstream.push("c_time", 0);
                jstream.push("c_round", 0);
                jstream.push("avg_bets", 0);
            }
            else if(user_action == RecordSystem_UserAction_Quit)
            {
                jstream.push("c_coin", PlayerMan::getInstance().getChangeCoin());
                jstream.push("c_gem", PlayerMan::getInstance().getChangeGold());
                jstream.push("c_level", PlayerMan::getInstance().getChangeLevel());
                jstream.push("c_time", PlayerMan::getInstance().getChangeTime());
                jstream.push("c_round", PlayerMan::getInstance().getChangeRound());
                jstream.push("avg_bets", PlayerMan::getInstance().getChangeBets());
            }
        }
        
        
        Log::getInstance()->output2Server(Log::GameRecord, content);
        
        if (roomId == 0 || subjectId == 0)
        {
            UserProductRecord(user_action == RecordSystem_UserAction_Enter?101:102, 0, 0, 0, cur_game);
        }
        else
        {
            UserProductRecord(user_action == RecordSystem_UserAction_Enter?103:104, 0, 0, 0, cur_game);
        }
    }
}
示例#16
0
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
bool Texture::save(std::string filename)
{
	if (!filename.length())
	{
		Log::printf("Texture::save failed to save the texture file %s (reason:  filename empty)\n");
		return false;
	}
  
  juce::File   jfile(juce::File::getCurrentWorkingDirectory().getChildFile(filename.c_str()));
  juce::String jext=jfile.getFileExtension().toLowerCase();

  if (jext==".tga")
  {
    if (!writeTga(filename,this))
      return false;
  }
  else
  {
    juce::ScopedPointer<juce::ImageFileFormat> jiff;

    if      (jext==".jpg" || jext==".jpeg") jiff=new juce::JPEGImageFormat();
    else if (jext==".png"                 ) jiff=new juce::PNGImageFormat();
    else if (jext==".git"                 ) jiff=new juce::GIFImageFormat();


    juce::Image jimg(bpp==8? (juce::Image::SingleChannel) : (bpp==24? juce::Image::RGB : juce::Image::ARGB),width,height,false);
    if (!jimg.isValid())
	  {
		  Log::printf("Texture::save failed to save the texture file %s \n",filename.c_str());
		  return false;
	  }

     if (!jiff)
     {
       Log::printf("Texture::save failed to save the texture file %s (reason: unsupported extension)\n",filename.c_str());
       return false;
     }

	  unsigned char* src=this->buffer;

    //Alpha
	  if (bpp==8)
	  {
		  for (unsigned int Y=0;Y<height;Y++) {
		  for (unsigned int X=0;X<width ;X++) {
        juce::Colour colour(src[0],src[0],src[0],src[0]);
        jimg.setPixelAt(X,height-Y-1,colour); //mirror y
			  src+=1;
		  }}
	  }
	  //RGB
	  else if (bpp==24)
	  {	
		  for (unsigned int Y=0;Y<height;Y++) {
		  for (unsigned int X=0;X<width ;X++) {
        juce::Colour colour(src[0],src[1],src[2]);
        jimg.setPixelAt(X,height-Y-1,colour); //mirror y
        src+=3;
		  }}
	  }
	  //RGBA
	  else if (bpp==32)
	  {
		  for (unsigned int Y=0;Y<height;Y++) {
		  for (unsigned int X=0;X<width ;X++) {
        juce::Colour colour(src[0],src[1],src[2],src[3]);
        jimg.setPixelAt(X,height-Y-1,colour); //mirror y
        src+=4;
		  }}
	  }

    if (jfile.existsAsFile()) 
      jfile.deleteFile();

    juce::FileOutputStream jstream(jfile);
    if (jstream.failedToOpen() || !jiff->writeImageToStream(jimg,jstream))
    {
		  Log::printf("Texture::save failed to save the texture file %s (reason: failedToOpen or writeImageToStream failed)\n",filename.c_str());
		  return false;
    }
  }

	this->filename=filename;	
	return true;
}
示例#17
0
void Log::output(const char *file, int line, Log::Level level, Log::Group group, const char *format, ...)
{
	int outputType = getActiveOutput(level, group);
	if(outputType == None)
		return;
	
	static char logtime[LOGTIME_SIZE];
	time_t now = time(0);
	strftime(logtime, sizeof(logtime), LOGTIME_FORMAT, localtime(&now));
	
	//write to buffer
    char jsonBuf[kLogMaxLogLen+1] = {0};
    
    if(outputType & Console || outputType & File)
    {
        snprintf(jsonBuf, kLogMaxLogLen, "TIME=%s LEVEL=%s GROUP=%s FILE=%s LINE=%d: ",logtime, getLevelString(level),getGroupString(group), getBaseName(file), line);
        
        size_t bufferMaxLength = kLogMaxLogLen-strlen(jsonBuf)-1;
        if(bufferMaxLength > 0)
        {
        #if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
            va_list ap;
            va_start(ap, format);
            vsnprintf_s(jsonBuf+strlen(jsonBuf), kLogMaxLogLen, kLogMaxLogLen, format, ap);
            va_end(ap);
        #else
            va_list ap;
            va_start(ap, format);
            vsnprintf(jsonBuf+strlen(jsonBuf), kLogMaxLogLen, format, ap);
            va_end(ap);
        #endif
            
            sprintf(jsonBuf+strlen(jsonBuf), "\n");
        }
        

        
        //write buffer to console
        if(outputType & Console)
        {
    #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
        __android_log_print(ANDROID_LOG_INFO, "LuckyCasino:","%s",jsonBuf);
    #else
        printf("%s",jsonBuf);
    #endif
        }
        
        if(outputType & File)
        {
            assert(m_outfileHandle);
            fwrite(jsonBuf, strlen(jsonBuf), 1, m_outfileHandle);
            fflush(m_outfileHandle);
        }
    }
	
	if(outputType & Network)
	{
        Json::Value jcontent;
        JsonStream jstream(jcontent);
        jstream.push("TIME", std::string(logtime));
        jstream.push("UDID", Utils::getUDID());
        jstream.push("PID", PlayerMan::getInstance().getPlayerId());
        jstream.push("LOGContent", std::string(jsonBuf));
        
        Json::Value root;
        JsonStream jrootstream(root);
        jrootstream.push("type", std::string(getGroupString(group)));
        jrootstream.push("value", jcontent);
        
		ScopedMutex _locker(m_mutexBuffer);
		m_networkBufList.push_back(root);
	}
}