Interface to the client's event loop. More...
#include <eventloop.h>
Public Member Functions | |
| virtual | ~EventLoop () |
| virtual void | listenForSocketRead (TPSocket *sock)=0 |
| Gives a TPSocket to the event loop to be alerted when it's ready to read. | |
| virtual void | listenForSocketWrite (TPSocket *sock)=0 |
| Gives a TPSocket to the event loop to be alerted when it's ready to write. | |
| virtual TimerConnection | setTimer (uint32_t interval, const TimerSignal::slot_type &callback)=0 |
| Sets up a timer to call in a given interval. | |
Interface to the client's event loop.
This class should be subclassed in every client to provide a way of integrating with the existing event loop, or a new event loop if required.
| virtual TPProto::EventLoop::~EventLoop | ( | ) | [inline, virtual] |
Required virtual destructor.
| virtual void TPProto::EventLoop::listenForSocketRead | ( | TPSocket * | sock | ) | [pure virtual] |
Gives a TPSocket to the event loop to be alerted when it's ready to read.
This needs to be implemented to have the TPSocket::isReadyToRead() method called when there is data waiting for the socket.
The socket is removed when it is disconnected.
The TPSocket::isReadyToRead() method can throw a DisconnectedException, which should be caught before returning to the underlying event loop.
| sock | The TPSocket to check |
Implemented in TPProto::SimpleEventLoop.
Referenced by TPProto::GameLayer::connect(), and TPProto::AdminLayer::connect().
| virtual void TPProto::EventLoop::listenForSocketWrite | ( | TPSocket * | sock | ) | [pure virtual] |
Gives a TPSocket to the event loop to be alerted when it's ready to write.
This needs to be implemented to have the TPSocket::isReadyToSend() method called when the socket is ready to send data.
This is a single shot, and should be disabled from from being triggered again before calling TPSocket::isReadyToSend().
The TPSocket::isReadyToSend() method can throw a DisconnectedException, which should be caught before returning to the underlying event loop.
| sock | The TPSocket to check |
Implemented in TPProto::SimpleEventLoop.
| virtual TimerConnection TPProto::EventLoop::setTimer | ( | uint32_t | interval, | |
| const TimerSignal::slot_type & | callback | |||
| ) | [pure virtual] |
Sets up a timer to call in a given interval.
| interval | The time interval before calling, in seconds | |
| callback | The slot/callback to call when the timer expires. |
Implemented in TPProto::SimpleEventLoop.
1.6.1