本文整理汇总了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);
}
示例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);
}
示例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;
}
示例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);
}
示例5: _encode
void NetStreamSender::_encode(NetStreamStorage & event, bool value){
event.writeByte(value?1:0);
}
示例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));
}
}
示例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;
}