TreeFrogFramework  1.18
Public Member Functions | Static Public Member Functions | Protected Member Functions | Friends | List of all members
TWebSocketEndpoint Class Reference

#include <twebsocketendpoint.h>

Inheritance diagram for TWebSocketEndpoint:
Inheritance graph
[legend]
Collaboration diagram for TWebSocketEndpoint:
Collaboration graph
[legend]

Public Member Functions

 TWebSocketEndpoint ()
 
virtual ~TWebSocketEndpoint ()
 
QString className () const
 
QString name () const
 
void sendText (const QString &text)
 
void sendBinary (const QByteArray &binary)
 
void ping (const QByteArray &payload=QByteArray())
 
void sendPing (const QByteArray &payload=QByteArray())
 
void close (int closeCode=Tf::NormalClosure)
 
void sendText (int sid, const QString &text)
 
void sendBinary (int sid, const QByteArray &binary)
 
void closeSocket (int sid, int closeCode=Tf::NormalClosure)
 
void rollbackTransaction ()
 
void subscribe (const QString &topic, bool local=true)
 
void unsubscribe (const QString &topic)
 
void unsubscribeFromAll ()
 
void publish (const QString &topic, const QString &text)
 
void publish (const QString &topic, const QByteArray &binary)
 
void startKeepAlive (int interval)
 
void sendHttp (int sid, const QByteArray &data)
 
const TWebSocketSessionsession () const
 
TWebSocketSessionsession ()
 
int socketId () const
 
QHostAddress peerAddress () const
 
quint16 peerPort () const
 

Static Public Member Functions

static bool isUserLoggedIn (const TSession &session)
 
static QString identityKeyOfLoginUser (const TSession &session)
 
static const QStringList & disabledEndpoints ()
 

Protected Member Functions

virtual bool onOpen (const TSession &session)
 
virtual void onClose (int closeCode)
 
virtual void onTextReceived (const QString &text)
 
virtual void onBinaryReceived (const QByteArray &binary)
 
virtual void onPing (const QByteArray &payload)
 
virtual void onPong (const QByteArray &payload)
 
virtual int keepAliveInterval () const
 
virtual bool transactionEnabled () const
 
void sendPong (const QByteArray &payload=QByteArray())
 

Friends

class TWebSocketWorker
 

Detailed Description

The TWebSocketEndpoint is the base class of endpoints for WebSocket communication.

Constructor & Destructor Documentation

TWebSocketEndpoint::TWebSocketEndpoint ( )
virtual TWebSocketEndpoint::~TWebSocketEndpoint ( )
inlinevirtual

Member Function Documentation

QString TWebSocketEndpoint::className ( ) const
inline

Returns the class name.

void TWebSocketEndpoint::close ( int  closeCode = Tf::NormalClosure)

Disconnects the WebSocket's connection with the client, closes the socket.

void TWebSocketEndpoint::closeSocket ( int  sid,
int  closeCode = Tf::NormalClosure 
)

Disconnects the WebSocket's connection of the id, closes the socket.

const QStringList & TWebSocketEndpoint::disabledEndpoints ( )
static
QString TWebSocketEndpoint::identityKeyOfLoginUser ( const TSession session)
static

Returns the identity key of the user, TAbstractUser object, logged in.

bool TWebSocketEndpoint::isUserLoggedIn ( const TSession session)
static

Returns true if a user is logged in to the system; otherwise returns false.

virtual int TWebSocketEndpoint::keepAliveInterval ( ) const
inlineprotectedvirtual
QString TWebSocketEndpoint::name ( ) const

Returns the endpoint name.

void TWebSocketEndpoint::onBinaryReceived ( const QByteArray &  binary)
protectedvirtual

This handler is called immediately after a binary message is received from the client.

void TWebSocketEndpoint::onClose ( int  closeCode)
protectedvirtual

This handler is called immediately when the WebSocket connection is closed.

bool TWebSocketEndpoint::onOpen ( const TSession session)
protectedvirtual

This handler is called immediately after the WebSocket connection is open.

If it returns false then the connection will be closed.

void TWebSocketEndpoint::onPing ( const QByteArray &  payload)
protectedvirtual

This handler is called immediately after a Ping frame is received from the client.

void TWebSocketEndpoint::onPong ( const QByteArray &  payload)
protectedvirtual

This handler is called immediately after a Pong frame is received from the client.

void TWebSocketEndpoint::onTextReceived ( const QString &  text)
protectedvirtual

This handler is called immediately after a text message is received from the client.

QHostAddress TWebSocketEndpoint::peerAddress ( ) const
inline
quint16 TWebSocketEndpoint::peerPort ( ) const
inline
void TWebSocketEndpoint::ping ( const QByteArray &  payload = QByteArray())

Pings the client to indicate that the connection is still alive.

void TWebSocketEndpoint::publish ( const QString &  topic,
const QString &  text 
)

Publishes the text message to all subscribers of the topic.

See also
subscribe(const QString &topic, bool local)
void TWebSocketEndpoint::publish ( const QString &  topic,
const QByteArray &  binary 
)

Publishes the binary message to subscribers of topic.

See also
subscribe(const QString &topic, bool local)
void TWebSocketEndpoint::rollbackTransaction ( )
inline

This function is called to rollback a transaction on the database.

void TWebSocketEndpoint::sendBinary ( const QByteArray &  binary)

Sends the given binary over the socket as a binary message.

void TWebSocketEndpoint::sendBinary ( int  sid,
const QByteArray &  binary 
)

Sends the given binary over the socket of the id as a binary message.

void TWebSocketEndpoint::sendHttp ( int  sid,
const QByteArray &  data 
)

Sends the given data over the HTTP socket of the id.

void TWebSocketEndpoint::sendPing ( const QByteArray &  payload = QByteArray())

Pings the client to indicate that the connection is still alive.

void TWebSocketEndpoint::sendPong ( const QByteArray &  payload = QByteArray())
protected

Sends a pong message.

Internal use.

void TWebSocketEndpoint::sendText ( const QString &  text)

Sends the given text over the socket as a text message.

void TWebSocketEndpoint::sendText ( int  sid,
const QString &  text 
)

Sends the given text over the socket of the id as a text message.

const TWebSocketSession & TWebSocketEndpoint::session ( ) const
inline

Returns the current WebSocket session, allows associating information with individual visitors.

TWebSocketSession & TWebSocketEndpoint::session ( )
inline

Returns the current WebSocket session, allows associating information with individual visitors.

QByteArray TWebSocketEndpoint::socketId ( ) const
inline

Returns the ID of this socket.

void TWebSocketEndpoint::startKeepAlive ( int  interval)

Starts pinging to this WebSocket.

When the interval time expires without communication, sends Ping frame over the connection to check that the link is operating.

void TWebSocketEndpoint::subscribe ( const QString &  topic,
bool  local = true 
)
bool TWebSocketEndpoint::transactionEnabled ( ) const
inlineprotectedvirtual

Must be overridden by subclasses to disable transaction mechanism.

The function must return false to disable the mechanism. This function returns true.

void TWebSocketEndpoint::unsubscribe ( const QString &  topic)

Unsubscribes the topic.

See also
subscribe(const QString &topic, bool local)
void TWebSocketEndpoint::unsubscribeFromAll ( )

Unsubscribes all subscribing topics.

See also
unsubscribe(const QString &topic)

Friends And Related Function Documentation

friend class TWebSocketWorker
friend

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