TreeFrogFramework  1.29
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::TWebSocketEndpoint ( )

◆ ~TWebSocketEndpoint()

virtual TWebSocketEndpoint::~TWebSocketEndpoint ( )
inlinevirtual

Member Function Documentation

◆ className()

QString TWebSocketEndpoint::className ( ) const
inline

Returns the class name.

◆ close()

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

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

◆ closeSocket()

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

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

◆ disabledEndpoints()

const QStringList & TWebSocketEndpoint::disabledEndpoints ( )
static

◆ identityKeyOfLoginUser()

QString TWebSocketEndpoint::identityKeyOfLoginUser ( const TSession session)
static

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

◆ isUserLoggedIn()

bool TWebSocketEndpoint::isUserLoggedIn ( const TSession session)
static

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

◆ keepAliveInterval()

virtual int TWebSocketEndpoint::keepAliveInterval ( ) const
inlineprotectedvirtual

◆ name()

QString TWebSocketEndpoint::name ( ) const

Returns the endpoint name.

◆ onBinaryReceived()

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

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

◆ onClose()

void TWebSocketEndpoint::onClose ( int  closeCode)
protectedvirtual

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

◆ onOpen()

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.

◆ onPing()

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

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

◆ onPong()

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

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

◆ onTextReceived()

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

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

◆ peerAddress()

QHostAddress TWebSocketEndpoint::peerAddress ( ) const
inline

◆ peerPort()

quint16 TWebSocketEndpoint::peerPort ( ) const
inline

◆ ping()

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

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

◆ publish() [1/2]

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)

◆ publish() [2/2]

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)

◆ rollbackTransaction()

void TWebSocketEndpoint::rollbackTransaction ( )
inline

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

◆ sendBinary() [1/2]

void TWebSocketEndpoint::sendBinary ( const QByteArray &  binary)

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

◆ sendBinary() [2/2]

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

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

◆ sendHttp()

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

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

◆ sendPing()

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

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

◆ sendPong()

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

Sends a pong message.

Internal use.

◆ sendText() [1/2]

void TWebSocketEndpoint::sendText ( const QString &  text)

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

◆ sendText() [2/2]

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

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

◆ session() [1/2]

TWebSocketSession& TWebSocketEndpoint::session ( )
inline

◆ session() [2/2]

TWebSocketSession & TWebSocketEndpoint::session ( ) const
inline

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

◆ socketId()

QByteArray TWebSocketEndpoint::socketId ( ) const
inline

Returns the ID of this socket.

◆ startKeepAlive()

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.

◆ subscribe()

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

◆ transactionEnabled()

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.

◆ unsubscribe()

void TWebSocketEndpoint::unsubscribe ( const QString &  topic)

Unsubscribes the topic.

See also
subscribe(const QString &topic, bool local)

◆ unsubscribeFromAll()

void TWebSocketEndpoint::unsubscribeFromAll ( )

Unsubscribes all subscribing topics.

See also
unsubscribe(const QString &topic)

Friends And Related Function Documentation

◆ TWebSocketWorker

friend class TWebSocketWorker
friend

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