当前位置: 首页>>代码示例>>C++>>正文


C++ raknet::RakString类代码示例

本文整理汇总了C++中raknet::RakString的典型用法代码示例。如果您正苦于以下问题:C++ RakString类的具体用法?C++ RakString怎么用?C++ RakString使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了RakString类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ExecStatementThread

SQLite3ServerPlugin::SQLExecThreadOutput ExecStatementThread(SQLite3ServerPlugin::SQLExecThreadInput threadInput, bool *returnOutput, void* perThreadData)
{
	unsigned int queryId;
	RakNet::RakString dbIdentifier;
	RakNet::RakString inputStatement;
	RakNet::BitStream bsIn((unsigned char*) threadInput.data, threadInput.length, false);
	bsIn.IgnoreBytes(sizeof(MessageID));
	bsIn.Read(queryId);
	bsIn.Read(dbIdentifier);
	bsIn.Read(inputStatement);
	// bool isRequest;
	// bsIn.Read(isRequest);
	bsIn.IgnoreBits(1);

	char *errorMsg;
	RakNet::RakString errorMsgStr;
	SQLite3Table outputTable;					
	sqlite3_exec(threadInput.dbHandle, inputStatement.C_String(), PerRowCallback, &outputTable, &errorMsg);
	if (errorMsg)
	{
		errorMsgStr=errorMsg;
		sqlite3_free(errorMsg);
	}

	RakNet::BitStream bsOut;
	bsOut.Write((MessageID)ID_SQLite3_EXEC);
	bsOut.Write(queryId);
	bsOut.Write(dbIdentifier);
	bsOut.Write(inputStatement);
	bsOut.Write(false);
	bsOut.Write(errorMsgStr);
	outputTable.Serialize(&bsOut);

	// Free input data
	rakFree_Ex(threadInput.data,_FILE_AND_LINE_);

	// Copy to output data
	SQLite3ServerPlugin::SQLExecThreadOutput threadOutput;
	threadOutput.data=(char*) rakMalloc_Ex(bsOut.GetNumberOfBytesUsed(),_FILE_AND_LINE_);
	memcpy(threadOutput.data,bsOut.GetData(),bsOut.GetNumberOfBytesUsed());
	threadOutput.length=bsOut.GetNumberOfBytesUsed();
	threadOutput.sender=threadInput.sender;	
	// SendUnified(&bsOut, MEDIUM_PRIORITY,RELIABLE_ORDERED,0,packet->systemAddress,false);

	*returnOutput=true;
	return threadOutput;
}
开发者ID:CaiZhongda,项目名称:ClashOfClans,代码行数:47,代码来源:SQLite3ServerPlugin.cpp

示例2: GetChangelistSinceDate

bool AutopatcherMySQLRepository::GetChangelistSinceDate(const char *applicationName, FileList *addedOrModifiedFilesWithHashData, FileList *deletedFiles, double sinceDate)
{
	char query[512];
	RakNet::RakString escapedApplicationName = GetEscapedString(applicationName);
	sprintf(query, "SELECT applicationID FROM Applications WHERE applicationName='%s';", escapedApplicationName.C_String());

	int applicationID;
	//sqlCommandMutex.Lock();
	if (!ExecuteQueryReadInt(query, &applicationID))
	{
		// This message covers the lost connection to the SQL server
		//sqlCommandMutex.Unlock();
		//sprintf(lastError,"ERROR: %s not found in UpdateApplicationFiles\n",escapedApplicationName.C_String());
		return false;
	}
	//sqlCommandMutex.Unlock();

	if (sinceDate!=0)
		sprintf(query,
		"SELECT filename, fileLength, contentHash, createFile, fileId FROM FileVersionHistory "
		"JOIN (SELECT max(fileId) maxId FROM FileVersionHistory WHERE applicationId=%i AND modificationDate > %f GROUP BY fileName) MaxId "
		"ON FileVersionHistory.fileId = MaxId.maxId "
		"ORDER BY filename DESC;", applicationID,sinceDate);
	else
		sprintf(query,
		"SELECT filename, fileLength, contentHash, createFile, fileId FROM FileVersionHistory "
		"JOIN (SELECT max(fileId) maxId FROM FileVersionHistory WHERE applicationId=%i GROUP BY fileName) MaxId "
		"ON FileVersionHistory.fileId = MaxId.maxId "
		"ORDER BY filename DESC;", applicationID);

	MYSQL_RES * result = 0;
	//sqlCommandMutex.Lock();
	if (!ExecuteBlockingCommand (query, &result))
	{
		//sqlCommandMutex.Unlock();
		return false;
	}
	//sqlCommandMutex.Unlock();

	MYSQL_ROW row;
	while ((row = mysql_fetch_row (result)) != 0)
	{
		const char * createFileResult = row [3]; 
		const char * hardDriveFilename = row [0];
		if (createFileResult[0]=='1')
		{
			const char * hardDriveHash = row [2]; 
			int fileLength = atoi (row [1]);
			addedFiles->AddFile(hardDriveFilename, hardDriveFilename, hardDriveHash, HASH_LENGTH, fileLength, FileListNodeContext(0,0), false);
		}
		else
		{
			deletedFiles->AddFile(hardDriveFilename,hardDriveFilename,0,0,0,FileListNodeContext(0,0), false);
		}
	}
	mysql_free_result (result);

	return true;
}
开发者ID:Darrenbydesign,项目名称:HoloToolkit,代码行数:59,代码来源:AutopatcherMySQLRepository.cpp

示例3: AddPassword

bool TwoWayAuthentication::AddPassword(RakNet::RakString identifier, RakNet::RakString password)
{
	if (password.IsEmpty())
		return false;

	if (identifier.IsEmpty())
		return false;

	if (password==identifier)
		return false; // Insecure

	if (passwords.GetIndexOf(identifier.C_String()).IsInvalid()==false)
		return false; // This identifier already in use

	passwords.Push(identifier, password,_FILE_AND_LINE_);
	return true;
}
开发者ID:Aasagi,项目名称:DICEProgrammingChallenge,代码行数:17,代码来源:TwoWayAuthentication.cpp

示例4: MessageResult

	virtual void MessageResult(RakNet::Notification_Console_MemberJoinedRoom *message)
	{
		RakNet::Notification_Console_MemberJoinedRoom_Steam *msgSteam = (RakNet::Notification_Console_MemberJoinedRoom_Steam *) message;
		RakNet::RakString msg;
		msgSteam->DebugMsg(msg);
		printf("%s\n", msg.C_String());
		// Guy with the lower ID connects to the guy with the higher ID
		uint64_t mySteamId=SteamUser()->GetSteamID().ConvertToUint64();
		if (mySteamId < msgSteam->srcMemberId)
		{
			// Steam's NAT punch is implicit, so it takes a long time to connect. Give it extra time
			unsigned int sendConnectionAttemptCount=24;
			unsigned int timeBetweenSendConnectionAttemptsMS=500;
			ConnectionAttemptResult car = rakPeer->Connect(msgSteam->remoteSystem.ToString(false), msgSteam->remoteSystem.GetPort(), 0, 0, 0, 0, sendConnectionAttemptCount, timeBetweenSendConnectionAttemptsMS);
			RakAssert(car==CONNECTION_ATTEMPT_STARTED);
		}
	}
开发者ID:dream7w,项目名称:ZRKServer,代码行数:17,代码来源:main.cpp

示例5: Hash

void TwoWayAuthentication::Hash(char thierNonce[TWO_WAY_AUTHENTICATION_NONCE_LENGTH], RakNet::RakString password, char out[HASHED_NONCE_AND_PW_LENGTH])
{
#if LIBCAT_SECURITY==1
	cat::Skein hash;
	if (!hash.BeginKey(HASH_BITS)) return;
	hash.Crunch(thierNonce, TWO_WAY_AUTHENTICATION_NONCE_LENGTH);
	hash.Crunch(password.C_String(), (int) password.GetLength());
	hash.End();
	hash.Generate(out, HASH_BYTES, STRENGTHENING_FACTOR);
#else
	CSHA1 sha1;
	sha1.Update((unsigned char *) thierNonce, TWO_WAY_AUTHENTICATION_NONCE_LENGTH);
	sha1.Update((unsigned char *) password.C_String(), (unsigned int) password.GetLength());
	sha1.Final();
	sha1.GetHash((unsigned char *) out);
#endif
}
开发者ID:Aasagi,项目名称:DICEProgrammingChallenge,代码行数:17,代码来源:TwoWayAuthentication.cpp

示例6: receiveGameServerConnectionInfo

void loginServer::receiveGameServerConnectionInfo(RakNet::Packet *packet) {//Receive data for connecting to game server
    RakNet::BitStream data(packet->data+sizeof(RakNet::MessageID),packet->length-sizeof(RakNet::MessageID),false);
    unsigned char ticket[8];
    for(char i=0; i<8; i++) {
        data.Read<unsigned char>(ticket[i]); //Read byte of the ticket
    }
    RakNet::RakString connectIP;
    short connectPort;
    data.Read<RakNet::RakString>(connectIP); //Read game server IP
    gameEngine::logger::logStream << "Connecting to server: " << connectIP.C_String() << endl;
    data.Read<short>(connectPort); //Read game serverPort
    //Now we need to try and connect to the game server
    networking::gameServer::parentWorld = networking::loginServer::parentWorld; //Set the parent world to the main menu world
    for(char i=0; i<8; i++) {
        networking::gameServer::ticket[i] = ticket[i]; //Set the ticket data
    }
    networking::gameServer::connect(connectIP.C_String(),connectPort); //Connect
}
开发者ID:Screetch,项目名称:GrandTale,代码行数:18,代码来源:loginServerPackets.cpp

示例7: Read

RakString HTTPConnection::Read(void)
{
	if (results.IsEmpty())
		return RakString();

	RakNet::RakString resultStr = results.Pop();
    // const char *start_of_body = strstr(resultStr.C_String(), "\r\n\r\n");
	const char *start_of_body = strpbrk(resultStr.C_String(), "\001\002\003%");
    
    if(! start_of_body)
    {
		return RakString();
    }

	// size_t len = strlen(start_of_body);
	//printf("Returning result with length %i\n", len);
	return RakNet::RakString::NonVariadic(start_of_body);
}
开发者ID:JobsSteve,项目名称:rushgame,代码行数:18,代码来源:HTTPConnection.cpp

示例8: _findnext

int _findnext(long h, _finddata_t *f)
{
	RakAssert(h >= 0 && h < (long)fileInfo.Size());
	if (h < 0 || h >= (long)fileInfo.Size()) return -1;
        
	_findinfo_t* fi = fileInfo[h];

	while(true)
	{
		dirent* entry = readdir(fi->openedDir);
		if(entry == 0) return -1;

                // Only report stuff matching our filter
                if (fnmatch(fi->filter, entry->d_name, FNM_PATHNAME) != 0) continue;

                // To reliably determine the entry's type, we must do
                // a stat...  don't rely on entry->d_type, as this
                // might be unavailable!
                struct stat filestat;
                RakNet::RakString fullPath = fi->dirName + entry->d_name;             
                if (stat(fullPath, &filestat) != 0)
                {
                    RAKNET_DEBUG_PRINTF("Cannot stat %s\n", fullPath.C_String());
                    continue;
                }

                if (S_ISREG(filestat.st_mode))
                {
                    f->attrib = _A_NORMAL;
                } else if (S_ISDIR(filestat.st_mode))
                {
                    f->attrib = _A_SUBDIR;                    
                } else continue; // We are interested in files and
                                 // directories only. Links currently
                                 // are not supported.

                f->size = filestat.st_size;
                strncpy(f->name, entry->d_name, STRING_BUFFER_SIZE);
                
                return 0;
	}

	return -1;
}
开发者ID:bazhenovc,项目名称:nebula3,代码行数:44,代码来源:_FindFirst.cpp

示例9: if

void Lobby2Server::OnChangeHandle(Lobby2ServerCommand *command, bool calledFromThread)
{
	if (calledFromThread)
	{
		ThreadAction ta;
		ta.action=L2MID_Client_ChangeHandle;
		ta.command=*command;
		threadActionQueueMutex.Lock();
		threadActionQueue.Push(ta, __FILE__, __LINE__ );
		threadActionQueueMutex.Unlock();
		return;
	}

	unsigned int i;
	RakNet::RakString oldHandle;
	for (i=0; i < users.Size(); i++)
	{
		if (users[i]->callerUserId==command->callerUserId)
		{
			oldHandle=users[i]->userName;
			users[i]->userName=command->callingUserName;
			break;
		}
	}

	if (oldHandle.IsEmpty())
		return;

#if defined(__INTEGRATE_LOBBY2_WITH_ROOMS_PLUGIN)
	// Tell the rooms plugin about the handle change
	if (roomsPlugin)
	{
		roomsPlugin->ChangeHandle(oldHandle, command->callingUserName);
	}
	else if (roomsPluginAddress!=UNASSIGNED_SYSTEM_ADDRESS)
	{
		RakNet::BitStream bs;
		RoomsPlugin::SerializeChangeHandle(oldHandle,command->callingUserName,&bs);
		SendUnified(&bs,packetPriority, RELIABLE_ORDERED, orderingChannel, roomsPluginAddress, false);
	}
#endif
}
开发者ID:jochao,项目名称:HoloToolkit,代码行数:42,代码来源:Lobby2Server.cpp

示例10:

void RoomsBrowserGFx3_RakNet::LoadProperty(const char *propertyId, RakNet::RakString &propertyOut)
{
	XMLNode xMainNode=XMLNode::openFileHelper(pathToXMLPropertyFile.C_String(),"");
	if (xMainNode.isEmpty())
		return;
	XMLNode xNode=xMainNode.getChildNode(propertyId);
	LPCTSTR attr = xNode.getAttribute("value", 0);
	if (attr)
		propertyOut = attr;
	else
		propertyOut.Clear();
}
开发者ID:dream7w,项目名称:ZRKServer,代码行数:12,代码来源:RoomsBrowserGFx3_RakNet.cpp

示例11: NewFile

// File RPC's
void NewFile( RakNet::BitStream * pBitStream, RakNet::Packet * pPacket )
{
	// Read the file type
	bool bIsScript;
	pBitStream->Read( bIsScript );

	// Read the file name
	RakNet::RakString strFileName;
	pBitStream->Read( strFileName );

	// Read the file path
	RakNet::RakString strFilePath;
	pBitStream->Read( strFilePath );

	// Read the file checksum
	CFileChecksum fileChecksum;
	pBitStream->Read( (char *)&fileChecksum, sizeof(CFileChecksum) );

	// Add the file to the transfer manager
	pCore->GetFileTransferManager()->Add ( strFileName.C_String (), strFilePath.C_String (), fileChecksum, bIsScript );
}
开发者ID:DarkKlo,项目名称:maf2mp,代码行数:22,代码来源:CNetworkRPC.cpp

示例12: DebugMsg

void Console_SearchRooms_Steam::DebugMsg(RakNet::RakString &out) const
{
    if (resultCode!=L2RC_SUCCESS)
    {
        Console_SearchRooms::DebugMsg(out);
        return;
    }
    out.Set("%i rooms found", roomNames.GetSize());
    for (DataStructures::DefaultIndexType i=0; i < roomNames.GetSize(); i++)
    {
        out += RakNet::RakString("\n%i. %s. ID=%" PRINTF_64_BIT_MODIFIER "u", i+1, roomNames[i].C_String(), roomIds[i]);
    }
}
开发者ID:krzyzacy,项目名称:Winter-Wars-PC-,代码行数:13,代码来源:Lobby2Message_Steam.cpp

示例13: FormatForDELETE

RakString RakString::FormatForDELETE(const char* uri, const char* extraHeaders)
{
	RakString out;
	RakString host;
	RakString remotePath;
	RakNet::RakString header;
	RakNet::RakString uriRs;
	uriRs = uri;

	uriRs.SplitURI(header, host, remotePath);
	if (host.IsEmpty() || remotePath.IsEmpty())
		return out;

	if (extraHeaders && extraHeaders[0])
	{
		out.Set("DELETE %s HTTP/1.1\r\n"
			"%s\r\n"
			"Content-Length: 0\r\n"
			"Host: %s\r\n"
			"Connection: close\r\n"
			"\r\n",
			remotePath.C_String(),
			extraHeaders,
			host.C_String());
	}
	else
	{
		out.Set("DELETE %s HTTP/1.1\r\n"
			"Content-Length: 0\r\n"
			"Host: %s\r\n"
			"Connection: close\r\n"
			"\r\n",
			remotePath.C_String(),
			host.C_String());
	}

	return out;
}
开发者ID:Napoleon314,项目名称:Venus2D,代码行数:38,代码来源:RakString.cpp

示例14: _findfirst

/**
* _findfirst - equivalent
*/
long _findfirst(const char *name, _finddata_t *f)
{
	RakNet::RakString nameCopy = name;
        RakNet::RakString filter;

        // This is linux only, so don't bother with '\'
	const char* lastSep = strrchr(name,'/');
	if(!lastSep)
	{
            // filter pattern only is given, search current directory.
            filter = nameCopy;
            nameCopy = ".";
	} else
	{
            // strip filter pattern from directory name, leave
            // trailing '/' intact.
            filter = lastSep+1;
            unsigned sepIndex = lastSep - name;
            nameCopy.Erase(sepIndex+1, nameCopy.GetLength() - sepIndex-1);
	}

	DIR* dir = opendir(nameCopy);
        
	if(!dir) return -1;

	_findinfo_t* fi = new _findinfo_t;
	fi->filter    = filter;
	fi->dirName   = nameCopy;  // we need to remember this for stat()
	fi->openedDir = dir;
	fileInfo.Insert(fi);

        long ret = fileInfo.Size()-1;

        // Retrieve the first file. We cannot rely on the first item
        // being '.'
        if (_findnext(ret, f) == -1) return -1;
        else return ret;
}
开发者ID:bazhenovc,项目名称:nebula3,代码行数:41,代码来源:_FindFirst.cpp

示例15: SplitURI

void RakString::SplitURI(RakNet::RakString &header, RakNet::RakString &domain, RakNet::RakString &path)
{
	header.Clear();
	domain.Clear();
	path.Clear();

	size_t strLen = strlen(sharedString->c_str);

	char c;
	unsigned int i=0;
	if (strncmp(sharedString->c_str, "http://", 7)==0)
		i+=(unsigned int) strlen("http://");
	else if (strncmp(sharedString->c_str, "https://", 8)==0)
		i+=(unsigned int) strlen("https://");
	
	if (strncmp(sharedString->c_str, "www.", 4)==0)
		i+=(unsigned int) strlen("www.");

	if (i!=0)
	{
		header.Allocate(i+1);
		strncpy(header.sharedString->c_str, sharedString->c_str, i);
		header.sharedString->c_str[i]=0;
	}


	domain.Allocate(strLen-i+1);
	char *domainOutput=domain.sharedString->c_str;
	unsigned int outputIndex=0;
	for (; i < strLen; i++)
	{
		c=sharedString->c_str[i];
		if (c=='/')
		{
			break;
		}
		else
		{
			domainOutput[outputIndex++]=sharedString->c_str[i];
		}
	}

	domainOutput[outputIndex]=0;

	path.Allocate(strLen-header.GetLength()-outputIndex+1);
	outputIndex=0;
	char *pathOutput=path.sharedString->c_str;
	for (; i < strLen; i++)
	{
		pathOutput[outputIndex++]=sharedString->c_str[i];
	}
	pathOutput[outputIndex]=0;
}
开发者ID:Napoleon314,项目名称:Venus2D,代码行数:53,代码来源:RakString.cpp


注:本文中的raknet::RakString类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。