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


C++ WriteBuffer::AppendByte方法代码示例

本文整理汇总了C++中WriteBuffer::AppendByte方法的典型用法代码示例。如果您正苦于以下问题:C++ WriteBuffer::AppendByte方法的具体用法?C++ WriteBuffer::AppendByte怎么用?C++ WriteBuffer::AppendByte使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WriteBuffer的用法示例。


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

示例1: WriteSummary

void LobbyGame::WriteSummary(WriteBuffer &theMsg)
{
	if(mGameType==LobbyGameType_Internet)
		theMsg.AppendBytes(mIPAddr.GetSixByte(),6);
	else
		theMsg.AppendShort(LobbyMisc::GetLanProductId());
	
	theMsg.AppendBool(mInProgress);
	if(mGameType!=LobbyGameType_Internet)
		theMsg.AppendWString(mName);

	theMsg.AppendByte(mSkillLevel);
	if(mGameType!=LobbyGameType_Internet)
	{
		unsigned char aProtectionFlags = 0;
		if(!mPassword.empty()) aProtectionFlags |= 0x01;
		if(mInviteOnly) aProtectionFlags |= 0x02;
		if(mAskToJoin) aProtectionFlags |= 0x04;
		theMsg.AppendByte(aProtectionFlags);
	}

	theMsg.AppendShort(mNumPlayers);
	theMsg.AppendShort(mMaxPlayers);

	WriteSummaryHook(theMsg);
}
开发者ID:SOLARIC,项目名称:world-opponent-network,代码行数:26,代码来源:LobbyGame.cpp

示例2: Decrypt

WONStatus AuthSession::Decrypt(ByteBufferPtr &theMsg)
{
	mLastUseTime = time(NULL);

	try
	{
		if(mAuthType==AUTH_TYPE_NONE || mAuthType==AUTH_TYPE_PERSISTENT_NOCRYPT)
			return WS_Success;

		ReadBuffer anIn(theMsg->data(),theMsg->length());
		WriteBuffer anOut;
		unsigned char headerType = anIn.ReadByte();
		switch (headerType)
		{
			case 2:							break;	//WONMsg::EncryptedService:
			case 4:	anOut.AppendByte(3);	break;	//WONMsg::MiniEncryptedService:
			case 6:	anOut.AppendByte(5);	break;	//WONMsg::SmallEncryptedService:
			case 8:	anOut.AppendByte(7);	break;	//WONMsg::LargeEncryptedService:
			case 12:						break;	//WONMsg::HeaderEncryptedService:

			default:
				return WS_Success;
		}

		bool sessioned = mAuthType==AUTH_TYPE_SESSION;

		if(sessioned)
		{
			unsigned short aSessionId = anIn.ReadShort();
			if(aSessionId!=mId)
				return WS_AuthSession_DecryptSessionIdMismatch;
		}

		ByteBufferPtr aDecrypt = mKey.Decrypt(anIn.data() + anIn.pos(), anIn.length() - anIn.pos());
		if(aDecrypt.get()==NULL)
			return WS_AuthSession_DecryptFailure;

		if(sessioned)
		{
			if(aDecrypt->length()<2)
				return WS_AuthSession_DecryptBadLen;

			if(++mInSeq!=ShortFromLittleEndian(*(unsigned short*)aDecrypt->data())) // sequence mismatch
				return WS_AuthSession_DecryptInvalidSequenceNum;

			anOut.AppendBytes(aDecrypt->data()+2,aDecrypt->length()-2);
		}
		else
			anOut.AppendBytes(aDecrypt->data(),aDecrypt->length());

		theMsg = anOut.ToByteBuffer();
		return WS_Success;
	}
	catch(ReadBufferException&)
	{
		return WS_AuthSession_DecryptUnpackFailure;
	}
}
开发者ID:Joincheng,项目名称:lithtech,代码行数:58,代码来源:AuthSession.cpp

示例3: GetRequest

ByteBufferPtr MultiPingOp::GetRequest(MultiPingStruct *theStruct)
{
	theStruct->mPingId = rand();
	theStruct->mStartPingTick = GetTickCount();

	WriteBuffer aBuf;
	aBuf.AppendByte(3);
	aBuf.AppendByte(1);
	aBuf.AppendByte(5);
	aBuf.AppendLong(theStruct->mPingId);
	aBuf.AppendBool(false);
	return aBuf.ToByteBuffer();
}
开发者ID:SOLARIC,项目名称:world-opponent-network,代码行数:13,代码来源:MultiPingOp.cpp

示例4: SendReadyRequest

void StagingLogic::SendReadyRequest(bool isReady)
{
	WriteBuffer aMsg;
	aMsg.AppendByte(LobbyGameMsg_ReadyRequest);
	aMsg.AppendBool(isReady);
	SendGameMessageToCaptain(aMsg.ToByteBuffer());
}
开发者ID:SOLARIC,项目名称:world-opponent-network,代码行数:7,代码来源:StagingLogic.cpp

示例5: AppendHashes

void AuthContext::AppendHashes(WriteBuffer &theBuf, const RawBuffer &theChallengeSeed)
{
	AutoCrit aCrit(mDataCrit);

	int aNumHashes = 0;
	int aNumHashPos = theBuf.length();
	theBuf.SkipBytes(1); // put num hashes here

	AuthLoginCommunityMap::iterator anItr = mCommunityMap.begin();
	while(anItr!=mCommunityMap.end())
	{
		AuthLoginCommunityData &aData = anItr->second;
		if(!aData.mSimpleHash.empty())
		{
			MD5Digest aKeyedHash;
			aKeyedHash.update(theChallengeSeed);
			aKeyedHash.update(aData.mKeyedHashData);
			RawBuffer aKeyedHashBuf = aKeyedHash.digest();		
	

			theBuf.AppendByte(1); // hash tag
			theBuf.AppendWString(anItr->first); // community
			theBuf.AppendBytes(aData.mSimpleHash.data(),aData.mSimpleHash.length());
			theBuf.AppendBytes(aKeyedHashBuf.data(),aKeyedHashBuf.length());
			aNumHashes++;
		}

		++anItr;
	}

	theBuf.SetByte(aNumHashPos,aNumHashes);
}
开发者ID:Joincheng,项目名称:lithtech,代码行数:32,代码来源:AuthContext.cpp

示例6: GetJoinGameRequest

ByteBufferPtr LobbyGame::GetJoinGameRequest()
{
	WriteBuffer aBuf;
	aBuf.AppendByte(LobbyGameMsg_JoinRequest);
	aBuf.AppendShort(mPing);
	GetJoinGameRequestHook(aBuf);
	return aBuf.ToByteBuffer();
}
开发者ID:SOLARIC,项目名称:world-opponent-network,代码行数:8,代码来源:LobbyGame.cpp

示例7: SendDissolveGame

void StagingLogic::SendDissolveGame()
{
	if(!IAmCaptain())
		return;

	WriteBuffer aMsg;
	aMsg.AppendByte(LobbyGameMsg_DissolveGame);
	BroadcastGameMessage(aMsg.ToByteBuffer());
}
开发者ID:SOLARIC,项目名称:world-opponent-network,代码行数:9,代码来源:StagingLogic.cpp

示例8: HandleJoinGameRequest

ByteBufferPtr LobbyGame::HandleJoinGameRequest(ReadBuffer &theMsg, LobbyClient *theClient)
{
	WriteBuffer aBuf;
	aBuf.AppendByte(LobbyGameMsg_JoinReply);
	aBuf.AppendShort(0); // reserve space for status

	short aStatus  = HandleJoinGameRequest(theMsg,theClient,aBuf);
	aBuf.SetShort(1,aStatus);

	return aBuf.ToByteBuffer();
}
开发者ID:SOLARIC,项目名称:world-opponent-network,代码行数:11,代码来源:LobbyGame.cpp

示例9: NotifyPingChange

void StagingLogic::NotifyPingChange(LobbyGame *theGame)
{
	if(mGame.get()==NULL || IAmCaptain())
		return;
	
	if(!theGame->IsSameGame(mGame))
		return;

	WriteBuffer aMsg;
	aMsg.AppendByte(LobbyGameMsg_PingChangedRequest);
	aMsg.AppendShort(theGame->GetPing());
	SendGameMessageToCaptain(aMsg.ToByteBuffer());
}
开发者ID:SOLARIC,项目名称:world-opponent-network,代码行数:13,代码来源:StagingLogic.cpp

示例10: KickClient

void StagingLogic::KickClient(LobbyClient *theClient, bool isBan)
{
	if(theClient==NULL || mGame.get()==NULL || !IAmCaptain())
		return;

	WriteBuffer aMsg;
	aMsg.AppendByte(LobbyGameMsg_ClientKicked);
	aMsg.AppendShort(theClient->GetClientId());
	aMsg.AppendBool(isBan);
	BroadcastGameMessage(aMsg.ToByteBuffer());

	LobbyStagingPrv::NetKickClient(theClient,isBan);
}
开发者ID:SOLARIC,项目名称:world-opponent-network,代码行数:13,代码来源:StagingLogic.cpp

示例11: HandleReadyRequest

void StagingLogic::HandleReadyRequest(ReadBuffer &theMsg, LobbyClient *theSender)
{
	if(!IAmCaptain() || !theSender->IsPlayer())
		return;

	bool isReady = theMsg.ReadBool();
	if(theSender->IsPlayerReady()==isReady) // no change needed
		return;

	WriteBuffer aMsg;
	aMsg.AppendByte(LobbyGameMsg_PlayerReady);
	aMsg.AppendShort(theSender->GetClientId());
	aMsg.AppendBool(isReady);
	BroadcastGameMessage(aMsg.ToByteBuffer());
}
开发者ID:SOLARIC,项目名称:world-opponent-network,代码行数:15,代码来源:StagingLogic.cpp

示例12: EncodeToBuffer

ByteBufferPtr WIMDecoder::EncodeToBuffer(RawImagePtr theImage)
{
	if(theImage->GetType()!=RawImageType_32)
		return NULL;

	RawImage32 *anImage = (RawImage32*)theImage.get();
	
	WriteBuffer aBuf;
	aBuf.AppendBytes("WIM",3); // file format identifier
	aBuf.AppendLong(32); // file subtype (32-bit raw)
	aBuf.AppendByte(anImage->GetDoTransparency()?1:0); // apply transparency bit?
	aBuf.AppendLong(anImage->GetWidth());
	aBuf.AppendLong(anImage->GetHeight());
	aBuf.AppendBytes(anImage->GetImageData(), 4*anImage->GetWidth()*anImage->GetHeight());
	return aBuf.ToByteBuffer();
}
开发者ID:SOLARIC,项目名称:world-opponent-network,代码行数:16,代码来源:WIMDecoder.cpp

示例13: HandlePingChangedRequest

void StagingLogic::HandlePingChangedRequest(ReadBuffer &theMsg, LobbyClient *theSender)
{
	if(!IAmCaptain())
		return;

	unsigned short aPing = theMsg.ReadShort();

	LobbyPlayer *aPlayer = theSender->GetPlayer();
	if(aPlayer==NULL)
		return;

	WriteBuffer aMsg;
	aMsg.AppendByte(LobbyGameMsg_PingChanged);
	aMsg.AppendShort(theSender->GetClientId());
	aMsg.AppendShort(aPing);
	BroadcastGameMessage(aMsg.ToByteBuffer());
}
开发者ID:SOLARIC,项目名称:world-opponent-network,代码行数:17,代码来源:StagingLogic.cpp

示例14: RunHook

void ReportPatchStatusOp::RunHook()
{
	SetMessageType(DBProxyPatchServer);
	SetSubMessageType(mMsgType);

	// Pack the message data
	WriteBuffer requestData;
	requestData.AppendString(mProductName);
	requestData.AppendString(mConfigName);
	requestData.AppendString(mFromVersion);
	requestData.AppendString(mToVersion);
	requestData.AppendString(mNetAddress);		// patch url
	requestData.AppendByte(mPatchStatus);

	// Pack and call base class implementation
	SetProxyRequestData(requestData.ToByteBuffer());

	if(mUDPSocket.get()==NULL) // just do TCP ServerRequest
	{
		DBProxyOp::RunHook();
		return;
	}

	// Do UDP server request

	IPAddr anAddr = GetAddr();
	if(!anAddr.IsValid())
	{
		Finish(WS_ServerReq_NoServersSpecified);
		return;
	}

	Reset();
	unsigned char aLengthFieldSize = GetLengthFieldSize();
	SetLengthFieldSize(0);
	GetNextRequest();
	SetLengthFieldSize(aLengthFieldSize);
	SendBytesToOpPtr anOp = new SendBytesToOp(mRequest, anAddr, mUDPSocket);
	anOp->Run(GetMode(),GetTimeout());
	Finish(WS_Success);
}
开发者ID:SOLARIC,项目名称:world-opponent-network,代码行数:41,代码来源:ReportPatchStatusOp.cpp

示例15: GetDocument

ByteBufferPtr GetHTTPDocumentOp::GetDocument(HTTPDocOwner theOwner) const
{
	FILE *aFile = NULL;
	
	if(!mDocumentPath[theOwner].empty()) // fopen will assert if the path is empty in MS crt debug library
		aFile = fopen(mDocumentPath[theOwner].c_str(),"r");
	
	if(aFile==NULL)
	{
		return new ByteBuffer("");
//		return NULL;
	}

	const int SIZE = 1024;
	char aBuf[SIZE];

	WriteBuffer anOverallBuf;

	// Skip the first character in MOTD documents
	if (mDocType == HTTPDocType_MOTD)
	{
		int aChar = fgetc(aFile);
		if(aChar=='<') // optional HTML
			ungetc(aChar,aFile);
	}

	while(!feof(aFile))
	{
		int aNumRead = fread(aBuf,1,SIZE,aFile);
		if(aNumRead>0)
			anOverallBuf.AppendBytes(aBuf,aNumRead);
	}

	anOverallBuf.AppendByte(0);
	fclose(aFile);

	return anOverallBuf.ToByteBuffer();
}
开发者ID:SOLARIC,项目名称:world-opponent-network,代码行数:38,代码来源:GetHTTPDocumentOp.cpp


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