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


C++ NetStreamStorage类代码示例

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


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

示例1: NetStreamStorage

void NetStreamSender::graphClear(const string & source_id, long time_id){
  NetStreamStorage event = NetStreamStorage();
  event.writeByte(EVENT_CLEARED);
  event.writeString(source_id);
  event.writeLong(time_id);
  _sendEvent(event);  
}
开发者ID:szhorvat,项目名称:gs-netstream,代码行数:7,代码来源:netstream-sender.cpp

示例2: NetStreamStorage

void NetStreamSender::graphClear(const GS_STRING & source_id, GS_LONG time_id){
  NetStreamStorage event = NetStreamStorage();
  event.writeByte(EVENT_CLEARED);
  event.writeString(source_id);
  event.writeUnsignedVarInt(time_id);
  _sendEvent(event);  
}
开发者ID:OpenModelica,项目名称:OMCompiler-3rdParty,代码行数:7,代码来源:netstream-sender.cpp

示例3:

 // -----------------------------------------------------------------------
 NetStreamStorage NetStreamStorage::operator+(const NetStreamStorage &storage)
 {
   NetStreamStorage msg;
   msg.store.insert(msg.store.end(), store.begin(), store.end());
   msg.store.insert(msg.store.end(), storage.begin(), storage.end());
   return msg;
 }
开发者ID:albedium,项目名称:gs-netstream,代码行数:8,代码来源:netstream-storage.cpp

示例4: sendExact

	void
		NetStreamSocket::
		sendExact( const NetStreamStorage &b)
		throw( NetStreamSocketException )
	{
		int length = static_cast<int>(b.size());
		NetStreamStorage length_storage;
		length_storage.writeInt(length);
		vector<unsigned char> msg;
		msg.insert(msg.end(), length_storage.begin(), length_storage.end());
		msg.insert(msg.end(), b.begin(), b.end());
		send(msg);
	}
开发者ID:OpenModelica,项目名称:OMCompiler-3rdParty,代码行数:13,代码来源:netstream-socket.cpp

示例5: _encode

void NetStreamSender::_encode(NetStreamStorage & event, bool value){
  event.writeByte(value?1:0);
}
开发者ID:szhorvat,项目名称:gs-netstream,代码行数:3,代码来源:netstream-sender.cpp

示例6: _encode

void NetStreamSender::_encode(NetStreamStorage & event, const vector<GS_BOOL> & value){
  event.writeInt(value.size());
  for(vector<bool>::const_iterator i = value.begin(); i != value.end(); i++){
    event.writeByte((*i));
  }
}
开发者ID:OpenModelica,项目名称:OMCompiler-3rdParty,代码行数:6,代码来源:netstream-sender.cpp

示例7: receiveExact

	bool
		NetStreamSocket::
		receiveExact( NetStreamStorage &msg )
		throw( NetStreamSocketException )
	{
		/* receive length of vector */
		unsigned char * const bufLength = new unsigned char[4];
		int bytesRead = 0;
		int readThisTime = 0;
		
		while (bytesRead<4)
		{
			readThisTime = recv( socket_, (char*)(bufLength + bytesRead), 4-bytesRead, 0 );

			if( readThisTime <= 0 )
			{
				// BailOnNetStreamSocketError definitely throws an exception so clear up heap
				delete[] bufLength;
				BailOnNetStreamSocketError( "NetStreamSocket::receive() @ recv" );
			}

			bytesRead += readThisTime;
		}
		NetStreamStorage length_storage(bufLength,4);
		int NN = length_storage.readInt() - 4;

		/* receive vector */
		unsigned char * const buf = new unsigned char[NN];
		bytesRead = 0;
		readThisTime = 0;
		
		while (bytesRead<NN)
		{
			readThisTime = recv( socket_, (char*)(buf + bytesRead), NN-bytesRead, 0 );

			if( readThisTime <= 0 )
			{
				// BailOnNetStreamSocketError definitely throws an exception so clear up heap
				delete[] bufLength;
				delete[] buf;
				BailOnNetStreamSocketError( "netstream::NetStreamSocket::receive() @ recv" );
			}

			bytesRead += readThisTime;
		}
		msg.reset();
		msg.writePacket(buf, NN);
		
		if (verbose_)
		{
			cerr << "Rcvd Storage with "  << 4 + NN <<  " bytes via netstream::NetStreamSocket: [";
			for (int i=0; i < 4; ++i)
			{
				cerr << " " << (int)bufLength[i] << " ";
			}
			for (int i=0; i < NN; ++i)
			{
				cerr << " " << (int)buf[i] << " ";
			}
			cerr << "]" << endl;
		}

		delete[] buf;
		delete[] bufLength;
		return true;
	}
开发者ID:OpenModelica,项目名称:OMCompiler-3rdParty,代码行数:66,代码来源:netstream-socket.cpp


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