void RhoConnectClientImpl::handleSyncResult(rho::apiGenerator::CMethodResult& oResult) {
	if ( getSyncEngine().isNoThreadedMode() ) {
		oResult.setCollectionMode(true);
		const char* ret = (const char*)getSyncThread()->getRetValue();
		if (ret != 0) {
			oResult.setJSON( ret );
		}
	}
}
示例#2
0
    virtual void readLogFile(int limit, rho::apiGenerator::CMethodResult& oResult)
    {
        bool bOldSaveToFile = LOGCONF().isLogToFile();
        LOGCONF().setLogToFile(false);

        rho::common::CRhoFile oFile;
        if ( oFile.open( LOGCONF().getLogFilePath().c_str(), rho::common::CRhoFile::OpenReadOnly) )
        {
            int nFileSize = oFile.size();
            int nPos = LOGCONF().getLogTextPos();
            int nMaxSize = nFileSize > nPos ? nFileSize : nPos;
            if ( limit <= 0 || limit > nMaxSize)
                limit = nMaxSize;

            oResult.setCollectionMode(true);
            oResult.set("");
            oResult.setCollectionMode(false);

            oResult.getString().resize(limit);
            char* szStr = (char*)oResult.getString().c_str();

            if ( limit <= nPos )
            {
                oFile.setPosTo(nPos-limit);
                oFile.readData(szStr,0,limit);
            }else
            {
                oFile.setPosTo(nFileSize-(limit-nPos));
                int nRead = oFile.readData(szStr,0,limit);

                oFile.setPosTo(0);
                oFile.readData(szStr,nRead,limit-nRead);
            }

        }

        LOGCONF().setLogToFile(bOldSaveToFile);

        if ( oResult.hasCallback() )
            oResult.callCallback();

    }