VideoTools
|
An abstract base class for the GNet::Server's connection to a remote client. More...
#include <gserver.h>
Public Types | |
typedef std::string::size_type | size_type |
Public Member Functions | |
ServerPeer (Server::PeerInfo) | |
Constructor. More... | |
bool | send (const std::string &data, std::string::size_type offset=0U) |
Sends data down the socket to the peer. More... | |
bool | send (const std::vector< std::pair< const char *, size_t > > &data) |
Overload to send data using scatter-gather segments. More... | |
void | doDelete (const std::string &=std::string()) |
Does "onDelete(); delete this". | |
std::string | logId () const |
Returns an identification string for logging purposes. | |
virtual std::pair< bool, Address > | localAddress () const override |
Returns the local address. More... | |
virtual std::pair< bool, Address > | peerAddress () const override |
Returns the peer address. More... | |
virtual std::string | peerCertificate () const override |
Returns the peer's TLS certificate. More... | |
virtual void | readEvent () override |
Override from GNet::EventHandler. | |
virtual void | writeEvent () override |
Override from GNet::EventHandler. | |
void | doDeleteThis (int) |
Does delete this. Should only be used by the GNet::Server class. | |
virtual void | onException (std::exception &) g__final override |
Override from GNet::EventHandler. More... | |
Public Member Functions inherited from GNet::EventHandler | |
virtual | ~EventHandler () |
Destructor. | |
virtual void | exceptionEvent () |
Called for a socket-exception event. More... | |
Public Member Functions inherited from GNet::Connection | |
virtual | ~Connection () |
Destructor. | |
Public Member Functions inherited from GNet::SocketProtocolSink | |
virtual | ~SocketProtocolSink () |
Destructor. | |
Protected Member Functions | |
virtual | ~ServerPeer () |
Destructor. More... | |
virtual void | onDelete (const std::string &reason)=0 |
Called just before destruction. More... | |
virtual void | onSendComplete ()=0 |
Called after flow-control has been released and all residual data sent. More... | |
void | sslAccept () |
Waits for the peer to start a secure session. More... | |
StreamSocket & | socket () |
Returns a reference to the client-server connection socket. More... | |
Server * | server () |
Returns a pointer to the associated server object. More... | |
Protected Member Functions inherited from GNet::EventExceptionHandler | |
virtual | ~EventExceptionHandler () |
Destructor. | |
Protected Member Functions inherited from GNet::SocketProtocolSink | |
virtual void | onData (const char *, size_t)=0 |
Called when data is read from the socket. | |
virtual void | onSecure (const std::string &peer_certificate)=0 |
Called once the secure socket protocol has been successfully negotiated. More... | |
An abstract base class for the GNet::Server's connection to a remote client.
Instances are created on the heap by the Server::newPeer() override, and they delete themselves when the connection is lost.
|
explicit |
Constructor.
This constructor is only used from within the override of GServer::newPeer().
Definition at line 32 of file gserver.cpp.
|
protectedvirtual |
Destructor.
Note that objects will delete themselves when they detect that the connection has been lost – see doDelete().
Definition at line 47 of file gserver.cpp.
|
overridevirtual |
Returns the local address.
Pair.first is false on error. Override from GNet::Connection.
Implements GNet::Connection.
Definition at line 89 of file gserver.cpp.
|
protectedpure virtual |
Called just before destruction.
(Note that the object typically deletes itself.)
|
overridevirtual |
Override from GNet::EventHandler.
Calls doDelete(). Note that the exception text is available via onDelete(). (This is public so that a derived-class server containing something like a HeapClient can merge its exception events.)
Implements GNet::EventExceptionHandler.
Definition at line 77 of file gserver.cpp.
|
protectedpure virtual |
Called after flow-control has been released and all residual data sent.
If an exception is thrown in the override then this object catches it and deletes iteself by calling doDelete().
|
overridevirtual |
Returns the peer address.
Override from GNet::Connection.
Implements GNet::Connection.
Definition at line 95 of file gserver.cpp.
|
overridevirtual |
Returns the peer's TLS certificate.
Override from GNet::Connection.
Implements GNet::Connection.
Definition at line 100 of file gserver.cpp.
bool GNet::ServerPeer::send | ( | const std::string & | data, |
std::string::size_type | offset = 0U |
||
) |
Sends data down the socket to the peer.
Returns true if completely sent; returns false if flow control asserted (see onSendComplete()). If flow control is asserted then there should be no new calls to send() until onSendComplete() is triggered. Throws on error.
Definition at line 115 of file gserver.cpp.
bool GNet::ServerPeer::send | ( | const std::vector< std::pair< const char *, size_t > > & | data | ) |
Overload to send data using scatter-gather segments.
If false is returned then segment data pointers must stay valid until onSendComplete() is triggered.
Definition at line 120 of file gserver.cpp.
|
protected |
Returns a pointer to the associated server object.
Returns nullptr if the server has been destroyed.
|
protected |
Returns a reference to the client-server connection socket.
Definition at line 66 of file gserver.cpp.
|
protected |
Waits for the peer to start a secure session.
See also GNet::SocketProtocolSink::onSecure().
Definition at line 61 of file gserver.cpp.