19 #ifndef SRC_XRDCL_XRDCLASYNCMSGREADER_HH_
20 #define SRC_XRDCL_XRDCLASYNCMSGREADER_HH_
50 const std::string &strmname,
52 uint16_t substrmnb) : readstage( ReadStart ),
53 xrdTransport( xrdTransport ),
57 substrmnb( substrmnb ),
73 readstage = ReadStart;
96 inmsg = std::make_shared<Message>();
100 readstage = ReadHeader;
113 strmname.c_str(), inmsg.get(), inmsg->GetCursor() );
119 "of message %p", strmname.c_str(), inmsg.get() );
120 inmsg->ReAllocate( 16 );
121 readstage = ReadAttn;
125 inmsgsize = inmsg->GetCursor();
131 "of message %p", strmname.c_str(), inmsg.get() );
135 readstage = ReadRawData;
142 readstage = ReadMsgBody;
157 if( HasEmbeddedRsp() )
160 readstage = ReadHeader;
167 inmsgsize = inmsg->GetCursor();
168 readstage = ReadMsgBody;
180 inmsgsize = inmsg->GetCursor();
185 readstage = ReadDone;
194 uint32_t bytesRead = 0;
198 inmsgsize += bytesRead;
204 readstage = ReadDone;
215 inmsgsize = inmsg->GetCursor();
235 readstage = ReadRawData;
246 readstage = ReadMore;
254 readstage = ReadDone;
264 strmname.c_str(), inmsg.get(), inmsgsize );
266 strm.
OnIncoming( substrmnb, std::move( inmsg ), inmsgsize );
287 size_t btsleft = 8 - ( inmsg->GetCursor() - 8 );
291 XRootDStatus st = socket.
Read( inmsg->GetBufferAtCursor(), btsleft, btsrd );
295 inmsg->AdvanceCursor( btsrd );
304 return XRootDStatus();
307 inline bool IsStatusRsp()
313 inline bool HasEmbeddedRsp()
341 TransportHandler &xrdTransport;
343 const std::string &strmname;
351 std::shared_ptr<Message> inmsg;
353 MsgHandler *inhandler;
Utility class encapsulating reading response message logic.
void Reset()
Reset the state of the object (makes it ready to read out next msg)
XRootDStatus Read()
Read out the response from the socket.
virtual ~AsyncMsgReader()
Destructor.
AsyncMsgReader(TransportHandler &xrdTransport, Socket &socket, const std::string &strmname, Stream &strm, uint16_t substrmnb)
static Log * GetLog()
Get default log.
void Dump(uint64_t topic, const char *format,...)
Print a dump message.
virtual XRootDStatus ReadMessageBody(Message *msg, Socket *socket, uint32_t &bytesRead)
@ More
there are more (non-raw) data to be read
virtual XRootDStatus Read(char *buffer, size_t size, int &bytesRead)
MsgHandler * InstallIncHandler(std::shared_ptr< Message > &msg, uint16_t stream)
void OnIncoming(uint16_t subStream, std::shared_ptr< Message > msg, uint32_t bytesReceived)
Call back when a message has been reconstructed.
uint16_t InspectStatusRsp(uint16_t stream, MsgHandler *&incHandler)
Perform the handshake and the authentication for each physical stream.
virtual XRootDStatus GetBody(Message &message, Socket *socket)=0
virtual XRootDStatus GetHeader(Message &message, Socket *socket)=0
virtual XRootDStatus GetMore(Message &message, Socket *socket)=0
const uint16_t stError
An error occurred that could potentially be retried.
const uint64_t AsyncSockMsg
const uint16_t errCorruptedHeader
uint16_t code
Error type, or additional hints on what to do.
bool IsOK() const
We're fine.