• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ WriteBuffer类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: time

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


示例2: aComplete

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: close

void MavlinkSerial::async_write_end(const boost::system::error_code &error, std::size_t bytes_transferred)
{
  if (error)
  {
    close();
    return;
  }

  mutex_lock lock(mutex_);
  if (write_queue_.empty())
  {
    write_in_progress_ = false;
    return;
  }

  WriteBuffer *buffer = write_queue_.front();
  buffer->pos += bytes_transferred;
  if (buffer->nbytes() == 0)
  {
    write_queue_.pop_front();
    delete buffer;
  }

  if (write_queue_.empty())
    write_in_progress_ = false;
  else
    do_async_write(false);
}
开发者ID:byu-magicc,项目名称:fcu_io2,代码行数:28,代码来源:mavlink_serial.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: 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


示例6: staticWriteByte

 NTA_Int32 staticWriteByte(NTA_WriteBufferHandle handle, NTA_Byte value)
 {
   NTA_CHECK(handle != NULL);
   
   WriteBuffer * wb = reinterpret_cast<WriteBuffer *>(handle);
   return wb->write(value);
 }
开发者ID:Asele,项目名称:nupic.core,代码行数:7,代码来源:Buffer.cpp


示例7: staticGetData

 const Byte * staticGetData(NTA_WriteBufferHandle handle)
 {
   NTA_CHECK(handle != NULL);
   
   WriteBuffer * wb = reinterpret_cast<WriteBuffer *>(handle);
   return wb->getData();
 }
开发者ID:Asele,项目名称:nupic.core,代码行数:7,代码来源:Buffer.cpp


示例8: staticWriteBufferGetSize

 NTA_Size staticWriteBufferGetSize(NTA_WriteBufferHandle handle)
 {
   NTA_CHECK(handle != NULL);
   
   WriteBuffer * wb = reinterpret_cast<WriteBuffer *>(handle);
   return wb->getSize();
 }
开发者ID:Asele,项目名称:nupic.core,代码行数:7,代码来源:Buffer.cpp


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


示例10: Convert

	bool Convert(const VfsPath& daeFilename, const VfsPath& pmdFilename, CColladaManager::FileType type)
	{
		// To avoid always loading the DLL when it's usually not going to be
		// used (and to do the same on Linux where delay-loading won't help),
		// and to avoid compile-time dependencies (because it's a minor pain
		// to get all the right libraries to build the COLLADA DLL), we load
		// it dynamically when it is required, instead of using the exported
		// functions and binding at link-time.
		if (!dll.IsLoaded())
		{
			if (!TryLoadDLL())
				return false;

			if (!LoadSkeletonDefinitions())
			{
				dll.Unload(); // Error should have been logged already
				return false;
			}
		}

		// Set the filename for the logger to report
		set_logger(ColladaLog, const_cast<void*>(static_cast<const void*>(&daeFilename)));

		// We need to null-terminate the buffer, so do it (possibly inefficiently)
		// by converting to a CStr
		CStr daeData;
		{
			CVFSFile daeFile;
			if (daeFile.Load(m_VFS, daeFilename) != PSRETURN_OK)
				return false;
			daeData = daeFile.GetAsString();
		}

		// Do the conversion into a memory buffer
		// We need to check the result, as archive builder needs to know if the source dae
		//	was sucessfully converted to .pmd/psa
		int result = -1;
		WriteBuffer writeBuffer;
		switch (type)
		{
		case CColladaManager::PMD:
			result = convert_dae_to_pmd(daeData.c_str(), ColladaOutput, &writeBuffer);
			break;
		case CColladaManager::PSA:
			result = convert_dae_to_psa(daeData.c_str(), ColladaOutput, &writeBuffer);
			break;
		}

		// don't create zero-length files (as happens in test_invalid_dae when
		// we deliberately pass invalid XML data) because the VFS caching
		// logic warns when asked to load such.
		if (writeBuffer.Size())
		{
			Status ret = m_VFS->CreateFile(pmdFilename, writeBuffer.Data(), writeBuffer.Size());
			ENSURE(ret == INFO::OK);
		}

		return (result == 0);
	}
开发者ID:2asoft,项目名称:0ad,代码行数:59,代码来源:ColladaManager.cpp


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


示例12: staticWriteString

 NTA_Int32 staticWriteString(NTA_WriteBufferHandle handle, const NTA_Byte * value, NTA_Size size)
 {
   NTA_CHECK(handle != NULL);
   NTA_CHECK(value != NULL);
   
   WriteBuffer * wb = reinterpret_cast<WriteBuffer *>(handle);
   return wb->writeString(value, size);
 }
开发者ID:Asele,项目名称:nupic.core,代码行数:8,代码来源:Buffer.cpp


示例13: serializeBinary

void DataTypeFixedString::serializeBinary(const Field & field, WriteBuffer & ostr) const
{
	const String & s = get<const String &>(field);
	ostr.write(s.data(), std::min(s.size(), n));
	if (s.size() < n)
		for (size_t i = s.size(); i < n; ++i)
			ostr.write(0);
}
开发者ID:Aahart911,项目名称:ClickHouse,代码行数:8,代码来源:DataTypeFixedString.cpp


示例14: SendDissolveGame

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

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


示例15: staticWriteReal64Array

 NTA_Int32 staticWriteReal64Array(NTA_WriteBufferHandle handle, const NTA_Real64 * value, NTA_Size size)
 {
   NTA_CHECK(handle != NULL);
   NTA_CHECK(value != NULL);
   NTA_CHECK(size > 0);
   
   WriteBuffer * wb = reinterpret_cast<WriteBuffer *>(handle);
   return wb->write(value, size);
 }
开发者ID:Asele,项目名称:nupic.core,代码行数:9,代码来源:Buffer.cpp


示例16: queueSendTo

void Connection::queueSendTo(const boost::asio::ip::udp::endpoint &endpoint, WriteBuffer &writeBuffer)
{
    socket_.async_send_to(boost::asio::buffer(&writeBuffer.getPayload()[0], writeBuffer.getPayload().getSize()),
                          endpoint,
                          strand_.wrap(std::bind(&Connection::sendToHandler,
                                       this,
                                       endpoint,
                                       std::placeholders::_1,
                                       std::placeholders::_2)));
}
开发者ID:Genilson23,项目名称:emu,代码行数:10,代码来源:connection.cpp


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


示例18: move

unique_ptr<Card> PlayerServer::judge()
{
	auto card = move(GAME->drawCards(1).front());
	WriteBuffer wb;
	wb << card->id;
	GAME->notify(100, Notify_JudgeStart, wb);
	TRIEV(t_Judge, &card);
	wb.clear();
	wb << card->id;
	GAME->notify(100, Notify_JudgeEnd, wb);
	return card;
}
开发者ID:popkc,项目名称:FreeSanGuoSha,代码行数:12,代码来源:player.cpp


示例19: BitVector

SuccinctVector::SuccinctVector(WriteBuffer& buffer, usint block_bytes, usint universe_size) :
  BitVector()
{
  if(buffer.ownsData())
  {
    this->initializeFrom(buffer.stealData(), block_bytes, universe_size);
  }
  else
  {
    this->initializeUsing(buffer.rawData(), block_bytes, universe_size);
  }
}
开发者ID:alexandrutomescu,项目名称:complete-contigs,代码行数:12,代码来源:succinctvector.cpp


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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ WriteConcernOptions类代码示例发布时间:2022-05-31
下一篇:
C++ WriteBackManager类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap