本文整理汇总了C++中BinaryReader::read16方法的典型用法代码示例。如果您正苦于以下问题:C++ BinaryReader::read16方法的具体用法?C++ BinaryReader::read16怎么用?C++ BinaryReader::read16使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BinaryReader
的用法示例。
在下文中一共展示了BinaryReader::read16方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: receive
void RTMFPHandshake::receive(const SocketAddress& address, BinaryReader& request) {
if(!Session::receive(address, request))
return;
UInt8 marker = request.read8();
if(marker!=0x0b) {
ERROR("Marker handshake wrong : should be 0b and not ",Format<UInt8>("%.2x",marker));
return;
}
UInt16 time = request.read16();
UInt8 id = request.read8();
request.shrink(request.read16()); // length
BinaryWriter response(packet(),RTMFP_MAX_PACKET_SIZE);
response.clear(RTMFP_HEADER_SIZE+3); // header + type and size
UInt8 idResponse = handshakeHandler(id,address, request,response);
if (!idResponse)
return;
BinaryWriter(response.data() + RTMFP_HEADER_SIZE, 3).write8(idResponse).write16(response.size() - RTMFP_HEADER_SIZE - 3);
(UInt32&)farId = 0;
flush(0x0b, response.size());
}
示例2: receive
void RTMFPSession::receive(const SocketAddress& address, BinaryReader& packet) {
if (!Session::receive(address, packet))
return;
// Read packet
UInt8 marker = packet.read8()|0xF0;
_timeSent = packet.read16();
// with time echo
if(marker == 0xFD) {
UInt16 time = RTMFP::TimeNow();
UInt16 timeEcho = packet.read16();
if(timeEcho>time) {
if(timeEcho-time<30)
time=0;
else
time += 0xFFFF-timeEcho;
timeEcho = 0;
}
peer.setPing((time-timeEcho)*RTMFP_TIMESTAMP_SCALE);
}
else if(marker != 0xF9)
WARN("RTMFPPacket marker unknown : ", Format<UInt8>("%02x",marker));
// Variables for request (0x10 and 0x11)
UInt8 flags;
RTMFPFlow* pFlow=NULL;
UInt64 stage=0;
UInt64 deltaNAck=0;
UInt8 type = packet.available()>0 ? packet.read8() : 0xFF;
bool answer = false;
// Can have nested queries
while(type!=0xFF) {
UInt16 size = packet.read16();
PacketReader message(packet.current(),size);
switch(type) {
case 0x0c :
fail("failed on client side");
break;
case 0x4c :
/// Session death!
_failed = true; // to avoid the fail signal!!
kill();
return;
/// KeepAlive
case 0x01 :
if(!peer.connected)
fail("Timeout connection client");
else
writeMessage(0x41,0);
case 0x41 :
_timesKeepalive=0;
break;
case 0x5e : {
// RTMFPFlow exception!
UInt64 id = message.read7BitLongValue();
RTMFPWriter* pRTMFPWriter = writer(id);
if(pRTMFPWriter)
pRTMFPWriter->fail("Writer rejected on session ",name());
else
WARN("RTMFPWriter ", id, " unfound for failed signal on session ", name());
break;
}
case 0x18 :
/// This response is sent when we answer with a Acknowledgment negative
// It contains the id flow
// I don't unsertand the usefulness...
//pFlow = &flow(message.read8());
//stage = pFlow->stageSnd();
// For the moment, we considerate it like a exception
fail("ack negative from server"); // send fail message immediatly
break;
case 0x51 : {
/// Acknowledgment
UInt64 id = message.read7BitLongValue();
RTMFPWriter* pRTMFPWriter = writer(id);
if(pRTMFPWriter)
pRTMFPWriter->acknowledgment(message);
else
WARN("RTMFPWriter ",id," unfound for acknowledgment on session ",name());
break;
}
/// Request
// 0x10 normal request
// 0x11 special request, in repeat case (following stage request)
case 0x10 : {
//.........这里部分代码省略.........