21#ifndef G_NET_SERVER_PEER_H
22#define G_NET_SERVER_PEER_H
43 class ServerPeerConfig ;
44 class ServerPeerInfo ;
53 unsigned int idle_timeout{0U} ;
70 G_EXCEPTION( IdleTimeout ,
"idle timeout" ) ;
80 bool send(
const std::string & data , std::size_t offset = 0U ) ;
87 bool send(
const std::vector<G::string_view> & data ) ;
96 std::pair<bool,Address>
peerAddress()
const override ;
108 void doOnDelete(
const std::string & reason ,
bool done ) ;
120 virtual bool onReceive(
const char * data , std::size_t size , std::size_t eolsize , std::size_t linesize ,
char c0 ) = 0 ;
123 virtual void onDelete(
const std::string & reason ) = 0 ;
141 void expect( std::size_t ) ;
146 void readEvent()
override ;
147 void writeEvent()
override ;
148 void otherEvent( EventHandler::Reason )
override ;
149 std::string exceptionSourceId()
const override ;
152 void onData(
const char * , std::size_t )
override ;
160 void operator=(
const ServerPeer & ) = delete ;
164 void onIdleTimeout() ;
165 bool onDataImp(
const char * , std::size_t , std::size_t , std::size_t ,
char ) ;
169 std::shared_ptr<StreamSocket> m_socket ;
174 mutable std::string m_exception_source_id ;
The GNet::Address class encapsulates a TCP/UDP transport address.
An abstract interface which provides address information for a network connection.
A base class for classes that handle asynchronous events from the event loop.
A tuple containing an ExceptionHandler interface pointer and a bound 'exception source' pointer.
A mixin base class that identifies the source of an exception when delivered to GNet::ExceptionHandle...
A configuration structure for GNet::LineBuffer.
Provides information abount the state of a line buffer.
A class that does line buffering, supporting auto-detection of line endings and fixed-size block extr...
A structure that GNet::Server uses to configure its ServerPeer objects.
A structure used in GNet::Server::newPeer().
An abstract base class for the GNet::Server's connection to a remote client.
void expect(std::size_t)
Modifies the line buffer state so that it delivers a chunk of non-line-delimited data.
~ServerPeer() override
Destructor.
void secureAccept()
Waits for the peer to start a secure session.
virtual bool onReceive(const char *data, std::size_t size, std::size_t eolsize, std::size_t linesize, char c0)=0
Called on receipt of data. See GNet::LineBuffer.
std::string connectionState() const override
Returns the connection state display string.
bool send(const std::string &data, std::size_t offset=0U)
Sends data down the socket to the peer.
void doOnDelete(const std::string &reason, bool done)
Used by the Server class to call onDelete().
LineBufferState lineBuffer() const
Returns information about the state of the internal line-buffer.
std::pair< bool, Address > peerAddress() const override
Returns the peer address.
virtual void onDelete(const std::string &reason)=0
Called just before the Server deletes this ServerPeer as the result of an exception (but not as a res...
std::string peerCertificate() const override
Returns the peer's TLS certificate.
std::pair< bool, Address > localAddress() const override
Returns the local address.
StreamSocket & socket()
Returns a reference to the client-server connection socket.
virtual void onSendComplete()=0
Called after flow-control has been released and all residual data sent.
void onData(const char *, std::size_t) override
Override from GNet::SocketProtocolSink.
ServerPeer(ExceptionSink, const ServerPeerInfo &, const LineBufferConfig &)
Constructor.
An interface used by GNet::SocketProtocol to deliver data from a socket.
An interface for implementing a low-level TLS/SSL protocol layer on top of a connected non-blocking s...
A derivation of GNet::Socket for a stream socket.
A timer class template in which the timeout is delivered to the specified method.