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


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

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


在下文中一共展示了WriteBuffer::AppendShort方法的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: GetComplete

WONStatus PeerAuthServer::GetComplete(WONStatus theStatus, ByteBufferPtr &theComplete)
{
	mState = STATE_NOT_STARTED; // reset state now
	
	WriteBuffer aComplete(mLengthFieldSize);
	aComplete.AppendLong(203);					// Auth peer to peer service
	aComplete.AppendLong(53);					// Complete

	if(theStatus!=WS_Success)
	{
		aComplete.AppendShort(WS_CommServ_InvalidParameters); // failure status
		aComplete.AppendShort(1); // num errors
		aComplete.AppendString(WONStatusToString(theStatus));
	}
	else
	{
		aComplete.AppendShort(WS_Success);
		WriteBuffer anEncryptBuf;
		anEncryptBuf.AppendShort(mSecretA.GetKeyLen());
		anEncryptBuf.AppendBytes(mSecretA.GetKey(),mSecretA.GetKeyLen());

			
		ByteBufferPtr anEncrypt = mClientCertificate->GetPubKey().Encrypt(anEncryptBuf.data(),anEncryptBuf.length());
		if(anEncrypt.get()==NULL)
			return WS_PeerAuthServer_FailedToEncryptWithClientPubKey;

		aComplete.AppendShort(anEncrypt->length());
		aComplete.AppendBytes(anEncrypt->data(),anEncrypt->length());
		mSession = new AuthSession(mAuthType, 0, mSecretB, mLengthFieldSize);
	}
	
	theComplete = aComplete.ToByteBuffer();
	return WS_Success;
}
开发者ID:SOLARIC,项目名称:world-opponent-network,代码行数:34,代码来源:PeerAuthServer.cpp

示例3: aChallenge

WONStatus PeerAuthServer::GetChallenge1(ByteBufferPtr &theChallenge)
{
	WriteBuffer aChallenge(mLengthFieldSize);

	aChallenge.AppendLong(203);					// Auth peer to peer service
	aChallenge.AppendLong(51);					// Challenge1

	mSecretB.Create(8);
	WriteBuffer aChallengeSecret;
	aChallengeSecret.AppendShort(mSecretB.GetKeyLen());
	aChallengeSecret.AppendBytes(mSecretB.GetKey(),mSecretB.GetKeyLen());

	ByteBufferPtr anEncrypt = mClientCertificate->GetPubKey().Encrypt(aChallengeSecret.data(),aChallengeSecret.length());
	if(anEncrypt.get()==NULL)
		return WS_PeerAuthServer_FailedToEncryptWithClientPubKey;

	aChallenge.AppendShort(anEncrypt->length());
	aChallenge.AppendBytes(anEncrypt->data(),anEncrypt->length());

	if(mUseAuth2)
		aChallenge.AppendBuffer(mPeerData->GetCertificate2()->GetRawBuf(),2);
	else
		aChallenge.AppendBuffer(mPeerData->GetCertificate()->GetRawBuf(),2);

	theChallenge = aChallenge.ToByteBuffer();
	return WS_Success;
}
开发者ID:SOLARIC,项目名称:world-opponent-network,代码行数:27,代码来源:PeerAuthServer.cpp

示例4: SetNetAddrPort

void AddServiceOp::SetNetAddrPort(unsigned short thePort)
{
	WriteBuffer theBuf;
	theBuf.AppendShort( htons(thePort) );

	SetNetAddr(theBuf.ToByteBuffer());
}
开发者ID:Joincheng,项目名称:lithtech,代码行数:7,代码来源:AddEntityOp.cpp

示例5: Encrypt

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

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

	WriteBuffer aMsg(mLengthFieldSize);
	aMsg.AppendByte(12); // encrypted message

	WriteBuffer aSeqBuf;
	const char *aBuf = theMsg->data() + mLengthFieldSize;
	unsigned short aLen = theMsg->length() - mLengthFieldSize;

	if(mAuthType==AUTH_TYPE_SESSION)
	{
		aMsg.AppendShort(mId);
		aSeqBuf.AppendShort(++mOutSeq);
		aSeqBuf.AppendBytes(aBuf,aLen);
		aBuf = aSeqBuf.data();
		aLen = aSeqBuf.length();
	}

	ByteBufferPtr anEncrypt = mKey.Encrypt(aBuf,aLen);
	if(anEncrypt.get()==NULL)
		return WS_AuthSession_EncryptFailure;
	
	aMsg.AppendBytes(anEncrypt->data(),anEncrypt->length());
	theMsg = aMsg.ToByteBuffer();
	return WS_Success;
}
开发者ID:Joincheng,项目名称:lithtech,代码行数:31,代码来源:AuthSession.cpp

示例6: 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

示例7: 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

示例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: 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

示例10: 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

示例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: RunHook

void RemoveBannedKeyOp::RunHook()
{
	SetMessageType(DBProxyAccount);
	SetSubMessageType(MSGTYPE);
	mStatusList.clear();

	// Stores the message data
	WriteBuffer requestData;
	requestData.AppendWString(mCommunityName);
	requestData.AppendString(mProductName);

	requestData.AppendShort(mKeyList.size());
	for(std::list<std::string>::const_iterator anItr = mKeyList.begin(); anItr != mKeyList.end(); ++anItr)
		requestData.AppendString(*anItr,1);

	// Copy buffer into the class
	SetProxyRequestData(requestData.ToByteBuffer());

	DBProxyOp::RunHook();
}
开发者ID:SOLARIC,项目名称:world-opponent-network,代码行数:20,代码来源:BannedKeyOp.cpp

示例13: aMsg

WONStatus PeerAuthClient::GetChallenge2(ByteBufferPtr &challenge2)
{
	mState = STATE_AWAITING_COMPLETE;

	WriteBuffer aMsg(mLengthFieldSize);
		
	aMsg.AppendLong(203);								// Auth1 Peer To Peer
	aMsg.AppendLong(52);								// Auth1 Challenge 2

	WriteBuffer anEncryptBuf;
	anEncryptBuf.AppendShort(mSecretB.GetKeyLen());
	anEncryptBuf.AppendBytes(mSecretB.GetKey(), mSecretB.GetKeyLen());
	anEncryptBuf.AppendBytes(mSecretA.GetKey(), mSecretA.GetKeyLen());

	ByteBufferPtr anEncrypt = mServerCertificate->GetPubKey().Encrypt(anEncryptBuf.data(),anEncryptBuf.length());
	if(anEncrypt.get()==NULL)
		return WS_PeerAuthClient_Challenge2EncryptFailure;

	aMsg.AppendShort(anEncrypt->length());
	aMsg.AppendBytes(anEncrypt->data(),anEncrypt->length());
	challenge2 = aMsg.ToByteBuffer();
	return WS_Success;
}
开发者ID:Joincheng,项目名称:lithtech,代码行数:23,代码来源:PeerAuthClient.cpp

示例14: HandleJoinGameRequest

void StagingLogic::HandleJoinGameRequest(ReadBuffer &theMsg, LobbyClient *theSender)
{
	if(theSender->IsPlayer())
		return;

	ByteBufferPtr aReply = mGame->HandleJoinGameRequest(theMsg,theSender);
	if(aReply.get()==NULL)
		return;

	SendGameMessageToClient(theSender,aReply);
	
	LobbyPlayer *aPlayer = theSender->GetPlayer();
	if(aPlayer!=NULL) // client successfully joined the game, tell everyone else
	{
		WriteBuffer aPlayerJoined;
		aPlayerJoined.AppendByte(LobbyGameMsg_PlayerJoined);
		aPlayerJoined.AppendShort(theSender->GetClientId());
		aPlayer->WriteData(aPlayerJoined);
		BroadcastGameMessage(aPlayerJoined.ToByteBuffer());
		LobbyStaging::UpdateGameSummary();
		return;
	}

}
开发者ID:SOLARIC,项目名称:world-opponent-network,代码行数:24,代码来源:StagingLogic.cpp

示例15: AppendCommunityData

void AuthContext::AppendCommunityData(WriteBuffer &theBuf)
{
	AutoCrit aCrit(mDataCrit);
	theBuf.AppendByte(0);									// 0 community ids
	theBuf.AppendByte(mCommunityMap.size());				// num community names
	AuthLoginCommunityMap::iterator anItr = mCommunityMap.begin(); 
	while(anItr!=mCommunityMap.end())
	{
		theBuf.AppendWString(anItr->first);	// community name
		++anItr;
	}


	int aNumCommnityElementsPos = theBuf.length();
	theBuf.SkipBytes(2); 
	int aNumCommunityElements = 0;

	anItr = mCommunityMap.begin();
	while(anItr!=mCommunityMap.end()) // Append CD Keys
	{
		AuthLoginCommunityData &aData = anItr->second;
		if(aData.mCDKey.IsValid())
		{
			ByteBufferPtr aKey = anItr->second.mCDKey.GetRaw();
			if(aKey.get()!=NULL)
			{
				theBuf.AppendByte(1);			// Type = CD Key
				theBuf.AppendShort(anItr->first.length()*2 + aKey->length() + 2); // length of community + data
				theBuf.AppendWString(anItr->first);
				theBuf.AppendBytes(aKey->data(),aKey->length());
				aNumCommunityElements++;
			}
		}
		++anItr;
	}

	CDKeyCommunityJoinMap::iterator aKeyJoinItr = mCDKeyCommunityJoinMap.begin(); // Append Community Join By CDKey Info
	while(aKeyJoinItr!=mCDKeyCommunityJoinMap.end())
	{
		ByteBufferPtr aKey = aKeyJoinItr->second.GetRaw();
		if(aKey.get()!=NULL)
		{
			theBuf.AppendByte(7);			// Type = Join Community with CD Key
			theBuf.AppendShort(aKeyJoinItr->first.length()*2+2 + 4 + aKey->length()); // community name + commnityseq + key
			theBuf.AppendWString(aKeyJoinItr->first);
			theBuf.AppendLong(0);
			theBuf.AppendBytes(aKey->data(),aKey->length());
			aNumCommunityElements++;
		}
		++aKeyJoinItr;
	}

	SetCommunityUserDataMap::iterator aUserDataItr = mSetCommunityUserDataMap.begin(); // Append User Data for communities
	while(aUserDataItr!=mSetCommunityUserDataMap.end())
	{
		const ByteBuffer *aData = aUserDataItr->second;
		if(aData!=NULL)
		{
			theBuf.AppendByte(8);			// Type = SetCommunityUserData
			theBuf.AppendShort(aUserDataItr->first.length()*2+2 + 4 + aData->length()); // community name + commnityseq + key
			theBuf.AppendWString(aUserDataItr->first);
			theBuf.AppendLong(0);
			theBuf.AppendBuffer(aData);
			aNumCommunityElements++;
		}

		++aUserDataItr;
	}

	if(mSecretList.size()>0) 				// CD Keys -> append login secret
	{
		theBuf.AppendByte(6);				// Type = LoginSecret
		unsigned long aPos = theBuf.length();
		theBuf.SkipBytes(2);

		AppendLoginSecrets(theBuf);
		theBuf.SetShort(aPos,theBuf.length()-aPos-2);
		aNumCommunityElements++;
	}

	NicknameMap::iterator aNickItr = mNicknameMap.begin();
	while(aNickItr!=mNicknameMap.end())
	{
		const wstring& aKey = aNickItr->first;
		const wstring& aVal = aNickItr->second;

		theBuf.AppendByte(4); // retrieve nickname
		unsigned long aPos = theBuf.length();
		theBuf.SkipBytes(2);
		theBuf.AppendWString(aKey);
		theBuf.SetShort(aPos,theBuf.length()-aPos-2);
		aNumCommunityElements++;

		if(!aVal.empty())
		{
			theBuf.AppendByte(3); // set nickname
			unsigned long aPos = theBuf.length();
			theBuf.SkipBytes(2);
			theBuf.AppendWString(aKey);
			theBuf.AppendWString(aVal);
//.........这里部分代码省略.........
开发者ID:Joincheng,项目名称:lithtech,代码行数:101,代码来源:AuthContext.cpp


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