CatapultServer  v0.5.0.1 (Elephant)
SocketReader.h
Go to the documentation of this file.
1 
21 #pragma once
22 #include "PacketHandlers.h"
23 #include "ReaderIdentity.h"
24 #include "SocketOperationCode.h"
25 #include <memory>
26 
27 namespace catapult {
28  namespace ionet {
29  class BatchPacketReader;
30  class PacketIo;
31  }
32 }
33 
34 namespace catapult { namespace ionet {
35 
37  class SocketReader {
38  public:
40 
41  public:
42  virtual ~SocketReader() = default;
43 
44  public:
46  virtual void read(const ReadCallback& callback) = 0;
47  };
48 
50  std::unique_ptr<SocketReader> CreateSocketReader(
51  const std::shared_ptr<BatchPacketReader>& pReader,
52  const std::shared_ptr<PacketIo>& pWriter,
53  const ServerPacketHandlers& handlers,
54  const ReaderIdentity& identity);
55 }}
m_pWriter
std::shared_ptr< PacketIo > m_pWriter
Definition: SocketReader.cpp:125
CATAPULT_LOG
#define CATAPULT_LOG(SEV)
Writes a log entry to the default logger with SEV severity.
Definition: Logging.h:340
m_callback
SocketReader::ReadCallback m_callback
Definition: SocketReader.cpp:128
catapult::ionet::SocketReader::read
virtual void read(const ReadCallback &callback)=0
Reads and consumes one or more packets and calls callback on completion.
m_numOutstandingOperations
size_t m_numOutstandingOperations
Definition: SocketReader.cpp:132
m_pOperation
std::weak_ptr< PacketReadWriteOperation > m_pOperation
Definition: SocketReader.cpp:173
colorPrint.warning
def warning(*args)
Definition: colorPrint.py:10
m_state
size_t m_state
Definition: SocketReader.cpp:133
catapult::ionet::SocketReader
Reads and consumes packets from a socket.
Definition: SocketReader.h:37
SocketReader.h
catapult::ionet::ReaderIdentity
Identifying information about a reader.
Definition: ReaderIdentity.h:28
m_pReader
std::shared_ptr< BatchPacketReader > m_pReader
Definition: SocketReader.cpp:124
catapult::ionet::SocketReader::~SocketReader
virtual ~SocketReader()=default
catapult::ionet::SocketOperationCode
SocketOperationCode
Enumeration of socket operation results.
Definition: SocketOperationCode.h:50
PacketHandlers.h
PacketSocket.h
pReader
std::weak_ptr< ChainedSocketReader > pReader
Definition: PacketReaders.cpp:38
m_identity
const ReaderIdentity & m_identity
Definition: SocketReader.cpp:127
ReaderIdentity.h
m_handlers
const ServerPacketHandlers & m_handlers
Definition: SocketReader.cpp:126
CATAPULT_THROW_RUNTIME_ERROR
#define CATAPULT_THROW_RUNTIME_ERROR(MESSAGE)
Macro used to throw a catapult runtime error.
Definition: exceptions.h:167
catapult::ionet::CreateSocketReader
std::unique_ptr< SocketReader > CreateSocketReader(const std::shared_ptr< BatchPacketReader > &pReader, const std::shared_ptr< PacketIo > &pWriter, const ServerPacketHandlers &handlers, const ReaderIdentity &identity)
Creates a socket packet reader around pReader, pWriter and handlers given a reader identity.
Definition: SocketReader.cpp:179
catapult
Definition: AddressExtractionExtension.cpp:28
catapult::consumer
std::function< void(TArgs...)> consumer
A consumer function.
Definition: functions.h:35
catapult::ionet::ServerPacketHandlers
A collection of packet handlers where there is at most one handler per packet type.
Definition: PacketHandlers.h:62
SocketOperationCode.h
catapult::ionet::SocketReader::ReadCallback
consumer< SocketOperationCode > ReadCallback
Definition: SocketReader.h:39