BMA Server Framework
Public Member Functions | Public Attributes | Protected Member Functions | List of all members
core::Session Class Reference

#include <Session.h>

Inheritance diagram for core::Session:
Inheritance graph
[legend]
Collaboration diagram for core::Session:
Collaboration graph
[legend]

Public Member Functions

 Session (EPoll &ePoll, Service &service)
 
virtual void output (std::stringstream &data)
 
void send ()
 
void sendToAll ()
 
void sendToAll (SessionFilter filter)
 
- Public Member Functions inherited from core::TCPSocket
 TCPSocket (EPoll &ePoll)
 
void connect (IPAddress &address)
 
- Public Member Functions inherited from core::Socket
 Socket (EPoll &ePoll)
 
void shutdown ()
 
void setDescriptor (int descriptor)
 Set the descriptor for the socket.
 
int getDescriptor ()
 Get the descriptor for the socket.
 
void eventReceived (struct epoll_event event)
 Parse epoll event and call specified callbacks. More...
 
void write (std::string data)
 
void write (char *buffer, int length)
 
void output (std::stringstream &out)
 
virtual void onRegistered ()
 Called when the socket has finished registering with the epoll processing. More...
 
virtual void onUnregistered ()
 Called when the socket has finished unregistering for the epoll processing. More...
 
void enable (bool mode)
 Enable the socket to read or write based upon buffer.
 

Public Attributes

std::stringstream out
 
Serviceservice
 
- Public Attributes inherited from core::TCPSocket
IPAddress ipAddress
 
- Public Attributes inherited from core::Socket
class {
bufferSize
 
- Public Attributes inherited from core::Object
std::string name
 
std::string tag
 

Protected Member Functions

void onDataReceived (std::string data) override
 Called when data is received from the socket. More...
 
void onConnected () override
 Called when socket is open and ready to communicate. More...
 
virtual void protocol (std::string data)
 
- Protected Member Functions inherited from core::Socket
void setBufferSize (int length)
 
virtual void onTLSInit ()
 
virtual void receiveData (char *buffer, int bufferLength)
 

Additional Inherited Members

- Protected Attributes inherited from core::Socket
EPollePoll
 
bool shutDown = false
 

Detailed Description

Session

Session defines the nature of the interaction with the client and stores persistent data for a defined session. BMASession objects are not sockets but instead provide a communications control mechanism. Protocol conversations are provided through extensions from this object.

Member Function Documentation

◆ onConnected()

void core::Session::onConnected ( )
overrideprotectedvirtual

Called when socket is open and ready to communicate.

The onConnected method is called when the socket is ready to communicate. Writing to the socket can begin on this call to initiate a contact with the remote device.

Reimplemented from core::Socket.

◆ onDataReceived()

void core::Session::onDataReceived ( std::string  data)
overrideprotectedvirtual

Called when data is received from the socket.

The onDataReceived method is called when the socket has received an event from epoll and there is data ready to be read from the socket. The default handler will pull the data and put it into the streambuf for the socket. EPOLLIN

Parameters
datathe data that has been received from the socket.

Implements core::Socket.

◆ output()

void core::Session::output ( std::stringstream &  out)
virtual

The output method is called by a socket session (BMASession) 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.

Reimplemented in core::TLSSession.

◆ protocol()

void core::Session::protocol ( std::string  data = "")
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.

Reimplemented in core::TLSSession, and core::ConsoleSession.

◆ send()

void core::Session::send ( )

The send method is used to output the contents of the out stream to the session containing the stream.

◆ sendToAll() [1/2]

void core::Session::sendToAll ( )

Use this sendToAll method to output the contents of the out stream to all the connections on the server excluding the sender session.

◆ sendToAll() [2/2]

void core::Session::sendToAll ( SessionFilter  filter)

Use this sendToAll method to output the contents of the out stream to all the connections on the server excluding the sender session and the entries identified by the passed in filter object.


The documentation for this class was generated from the following files: