Wt
3.3.8
|
A utility class for asynchronous notification of socket activity. More...
#include <Wt/WSocketNotifier>
Public Types | |
Public Types inherited from Wt::WObject | |
typedef void(WObject::* | Method) () |
Typedef for a WObject method without arguments. | |
Public Member Functions | |
WSocketNotifier (int socket, Type type, WObject *parent=0) | |
Creates a new socket notifier. More... | |
~WSocketNotifier () | |
Destructor. | |
int | socket () const |
Returns the socket. | |
Type | type () const |
Returns the event type. | |
void | setEnabled (bool enabled) |
Enables or disable the notifier. More... | |
bool | isEnabled () const |
Returns if the notifier is enabled. | |
Signal< int > & | activated () |
Signal indicating an event. More... | |
Public Member Functions inherited from Wt::WObject | |
WObject (WObject *parent=0) | |
Create a WObject with a given parent object. More... | |
virtual | ~WObject () |
Destructor. More... | |
virtual const std::string | id () const |
Returns the (unique) identifier for this object. More... | |
virtual void | setObjectName (const std::string &name) |
Sets an object name. More... | |
virtual std::string | objectName () const |
Returns the object name. More... | |
void | resetLearnedSlots () |
Resets learned stateless slot implementations. More... | |
template<class T > | |
void | resetLearnedSlot (void(T::*method)()) |
Resets a learned stateless slot implementation. More... | |
template<class T > | |
WStatelessSlot * | implementStateless (void(T::*method)()) |
Declares a slot to be stateless and learn client-side behaviour on first invocation. More... | |
template<class T > | |
WStatelessSlot * | implementStateless (void(T::*method)(), void(T::*undoMethod)()) |
Declares a slot to be stateless and learn client-side behaviour in advance. More... | |
void | isNotStateless () |
Marks the current function as not stateless. More... | |
template<class T > | |
WStatelessSlot * | implementJavaScript (void(T::*method)(), const std::string &jsCode) |
Provides a JavaScript implementation for a method. More... | |
void | addChild (WObject *child) |
Adds a child object. More... | |
virtual void | removeChild (WObject *child) |
Removes a child object. More... | |
const std::vector< WObject * > & | children () const |
Returns the children. | |
WObject * | parent () const |
Returns the parent object. | |
Additional Inherited Members | |
Protected Member Functions inherited from Wt::WObject | |
virtual WStatelessSlot * | getStateless (Method method) |
On-demand stateless slot implementation. More... | |
Static Protected Member Functions inherited from Wt::WObject | |
static WObject * | sender () |
Returns the sender of the current slot call. More... | |
A utility class for asynchronous notification of socket activity.
Use a socket notifier to integrate listening for socket events into the Wt event loop. In this way, you do not need a separate thread to listen for socket activity. Socket activity is either the availability of data to be read (Read event), possibility to write data (Write event), or an exception that occurred (Exception event).
When an event on a socket is available, the notifier emits the activated() signal. As in the case of a user interface event (like for example WInteractWidget::clicked()), you will typically modify the widget tree in response to the event. But, unless you use a timer (WTimer) or use server-initiated updates (see WApplication::triggerUpdates()), these changes are not propagated to the user interface, until the next user interface event.
Like other events, socket notification events are serial (not simultaneous), and there are no thread safety issues (you don't need to take the WApplication::UpdateLock).
Creates a new socket notifier.
Create a new socket listener to listen for events of given type
on a socket with file descriptor socket
. The WSocketNotifier is enabled after construction.
Signal<int>& Wt::WSocketNotifier::activated | ( | ) |
Signal indicating an event.
The signal is emitted when an event that was waited for is available. The signal argument is socket().
void Wt::WSocketNotifier::setEnabled | ( | bool | enabled | ) |
Enables or disable the notifier.
By default, the socket notifier is enabled to receive events. When disabled, no events will be notified (as if the socket notifier didn't exist).