My Project
|
#include <TCPSession2.h>
Public Member Functions | |
TCPSession2 (EPoll &ePoll, std::string text="") | |
virtual void | output (std::stringstream &data) |
void | send () |
void | terminate () |
![]() | |
TCPSocket (EPoll &ePoll) | |
TCPSocket (EPoll &ePoll, std::string text) | |
void | connect (IPAddress &address) |
![]() | |
Socket (EPoll &ePoll, std::string text="") | |
virtual | ~Socket () |
void | shutdown (std::string text="unknown") |
void | setDescriptor (int descriptor) |
Set the descriptor for the socket. More... | |
int | getDescriptor () |
Get the descriptor for the socket. | |
bool | eventReceived (struct epoll_event event, long long eventId) |
Parse epoll event and call specified callbacks. More... | |
int | write (std::string data, Socket *sender=NULL) |
void | write (char *buffer, int length) |
void | output (std::stringstream &out) |
virtual void | onRegister () |
Called before the socket has registered with the epoll processing. More... | |
virtual void | onUnregister () |
virtual void | onUnregistered () |
Called when the socket has finished unregistering for the epoll processing. More... | |
bool | needsToWrite () |
Public Attributes | |
Command * | grab = NULL |
std::stringstream | out |
![]() | |
IPAddress | ipAddress |
![]() | |
bool | reset = false |
volatile bool | shutDown = false |
Protected Member Functions | |
virtual void | onRegistered () override |
Called after the socket has been registered with epoll processing. | |
virtual void | onDataReceived (coreutils::ZString &data) override |
virtual void | onLineReceived (coreutils::ZString &line) |
virtual void | onBlockReceived (coreutils::ZString &block) |
virtual void | onConnected () |
virtual void | protocol (coreutils::ZString &data) |
void | setBlockSize (int size=0) |
![]() | |
void | setBufferSize (int length) |
int | getBufferSize () |
virtual void | onDataReceived (std::string data) |
Called when data is received from the socket. More... | |
virtual void | receiveData (coreutils::ZString &buffer) |
Additional Inherited Members | |
![]() | |
EPoll & | ePoll |
TCPSession defines the nature of the interaction with the client and stores persistent data for a defined session. TCPSession objects are not sockets but instead provide a communications control mechanism. Protocol conversations are provided through extensions from this object.
TCPSession2 is designed to be 'connected' instead of being served by a server.
|
protectedvirtual |
Override the onBlockReceived method to receive a string of characters that represents a single block of data of length determined by the block length value. If onDataReceived was overriden this method will not be called unless the onDataReceived calls this method explicitly using the class and member name.
|
protectedvirtual |
This method is called from within the protocol method when protocol is called on the initial connection where the data is an empty string. Use this method to deliver a message to the connection upon connection.
|
overrideprotectedvirtual |
Override this method to receive data directly from the socket as data is received. If you need data split by line termination characters then override the onLineReceived method instead.
Reimplemented from core::Socket.
|
protectedvirtual |
Override the onLineReceived method to receive a string of characters that represents a single line of data terminated by a LF or CRLF. If onDataReceived was overriden this method will not be called unless the onDataReceived calls this method explicitly using the class and member name.
|
virtual |
The output method is called by a socket session (TCPSession) and will output the detail information for the client socket. When extending BMATCPSocket or BMASession you can override the method to add attributes to the list.
Reimplemented from core::TCPSocket.
|
protectedvirtual |
Override the protocol method to manage and control the session communications in your inherited session. If you do not override this method then the Session default will process the 'commands' added to the server object using the processRequest method on the session input.
When data is received within the session two modes are available to pass the data through the protocol method: LINE or BLOCK.
void core::TCPSession2::send | ( | ) |
The send method is used to output the contents of the out stream to the session containing the stream.
|
protected |
Use setBlockSize to set the amount of data that should be read at once from the session data buffer. If this value is set to 0 then the data will be retrieved
void core::TCPSession2::terminate | ( | ) |
Use this method to terminate this TCPSession.
std::stringstream core::TCPSession2::out |
Use out to send data to the session socket or other session sockets.