本文整理汇总了C++中PacketReader::write16方法的典型用法代码示例。如果您正苦于以下问题:C++ PacketReader::write16方法的具体用法?C++ PacketReader::write16怎么用?C++ PacketReader::write16使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PacketReader
的用法示例。
在下文中一共展示了PacketReader::write16方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: packetHandler
void ServerConnection::packetHandler(PacketReader& packet) {
UInt8 marker = packet.read8();
if(marker!=0x0b) {
ERROR("ServerConnection with an unknown %u marker, it should be 0x0b",marker);
return;
}
packet.next(2);
UInt8 id = packet.read8();
switch(id) {
case 0x71: {
packet.next(2);
string tag;
packet.readString8(tag);
map<string,P2PHandshakerAddress>::iterator it = _p2pHandshakers.find(tag);
if(it==_p2pHandshakers.end()) {
ERROR("Unknown ServerConnection tag %s on P2P handshake",tag.c_str());
break;
}
(SocketAddress&)_handshake.peer.address = it->second;
packet.reset(0);
PacketWriter writer(packet.current(),packet.available()+16); // +16 for futur 0xFFFF padding
writer.clear(packet.available());
_handshake.send(writer);
_p2pHandshakers.erase(it);
break;
}
case 0x40: {
if(!_connected) {
// Edge hello response
_connected=true;
return;
}
// Edge keepalive
PacketWriter& packet(writer());
packet.write8(0x41);
packet.write16(0);
flush();
INFO("Keepalive RTMFP server");
break;
}
case 0x45: {
// Server is death!
(bool&)died=true;
break;
}
default:
ERROR("Unkown ServerConnection packet id %u",id);
}
}