MCPcopy Create free account
hub / github.com/apache/brpc / OnPingRequest

Method OnPingRequest

src/brpc/policy/rtmp_protocol.cpp:2060–2085  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2058}
2059
2060bool RtmpChunkStream::OnPingRequest(const RtmpMessageHeader& mh,
2061 const butil::StringPiece& event_data,
2062 Socket* socket) {
2063 RtmpService* service = connection_context()->service();
2064 if (service != NULL) {
2065 RTMP_ERROR(socket, mh) << "Server should not receive `PingRequest'";
2066 return false;
2067 }
2068 if (event_data.size() != 4) {
2069 RTMP_ERROR(socket, mh) << "Invalid PingRequest.event_data.size="
2070 << event_data.size();
2071 return false;
2072 }
2073 const uint32_t timestamp = ReadBigEndian4Bytes(event_data.data());
2074 char data[6];
2075 char* p = data;
2076 WriteBigEndian2Bytes(&p, RTMP_USER_CONTROL_EVENT_PING_RESPONSE);
2077 WriteBigEndian4Bytes(&p, timestamp);
2078 SocketMessagePtr<RtmpUnsentMessage> msg(
2079 MakeUnsentControlMessage(RTMP_MESSAGE_USER_CONTROL, data, sizeof(data)));
2080 if (socket->Write(msg) != 0) {
2081 PLOG(WARNING) << "Fail to send back PingResponse";
2082 return false;
2083 }
2084 return true;
2085}
2086
2087bool RtmpChunkStream::OnPingResponse(const RtmpMessageHeader& mh,
2088 const butil::StringPiece& event_data,

Callers

nothing calls this directly

Calls 8

ReadBigEndian4BytesFunction · 0.85
WriteBigEndian2BytesFunction · 0.85
WriteBigEndian4BytesFunction · 0.85
MakeUnsentControlMessageFunction · 0.85
serviceMethod · 0.80
sizeMethod · 0.45
dataMethod · 0.45
WriteMethod · 0.45

Tested by

no test coverage detected