CFx SDK Documentation  2023 SP0
Public Types | Public Member Functions | List of all members
CFxNAWebSocket Class Reference

#include <FxNAWebSocket.h>

Inheritance diagram for CFxNAWebSocket:
CFxUIObject

Public Types

enum  SocketState {
  UnconnectedState , HostLookupState , ConnectingState , ConnectedState ,
  BoundState , ListeningState , ClosingState
}
 

Public Member Functions

 CFxNAWebSocket (const CFxNAString &origin=CFxNAString(), CFxNAWebSocketProtocol::Version version=CFxNAWebSocketProtocol::VersionLatest)
 
 ~CFxNAWebSocket ()
 
long long sendTextMessage (const CFxUIString &textMessage)
 
void open (const CFxNANetworkRequest &request)
 
void close (CFxNAWebSocketProtocol::CloseCode closeCode=CFxNAWebSocketProtocol::CloseCodeNormal, const CFxNAString &reason=CFxNAString())
 
CFxUISignal< void(void) > & connected ()
 
CFxUISignal< void(int) > & error ()
 
CFxUISignal< void(void) > & disconnected ()
 
CFxUISignal< void(const CFxNAString &) > & textMessageReceived ()
 
- Public Member Functions inherited from CFxUIObject
 CFxUIObject ()
 
virtual ~CFxUIObject ()
 
FxNativeHandle getHandle () const
 
void setHandle (FxNativeHandle handle)
 
void setParent (CFxUIObject *parent)
 
CFxUIObjectparent ()
 
const CFxUIObjectparent () const
 
void setObjectName (const CFxUIString &objectName)
 
CFxUIString objectName () const
 
bool setProperty (const char *name, const CFxUIVariant &value)
 
CFxUIVariant property (const char *name)
 
CFxUIList< CFxUIObject * > children () const
 
template<typename T >
CFxUIList< T > findChildren (const CFxUIString &name=CFxUIString())
 
void blockSignals (bool block)
 
bool signalsBlocked () const
 

Additional Inherited Members

- Protected Member Functions inherited from CFxUIObject
CFxUIObjectsender ()
 
- Protected Attributes inherited from CFxUIObject
CFxUIObjectImpl * m_pImpl
 
CFxUIObjectData * m_pData
 

Detailed Description

Class CFxNAWebSocket Implements a TCP socket that talks the WebSocket protocol.

Definition at line 33 of file FxNAWebSocket.h.

Member Enumeration Documentation

◆ SocketState

Enumerator
UnconnectedState 
HostLookupState 
ConnectingState 
ConnectedState 
BoundState 
ListeningState 
ClosingState 

Definition at line 36 of file FxNAWebSocket.h.

Constructor & Destructor Documentation

◆ CFxNAWebSocket()

CFxNAWebSocket::CFxNAWebSocket ( const CFxNAString origin = CFxNAString(),
CFxNAWebSocketProtocol::Version  version = CFxNAWebSocketProtocol::VersionLatest 
)
explicit

Constructor

Creates a new CFxNAWebSocket with the given origin, the version of the protocol to use.

Parameters
originInput
versionInput

◆ ~CFxNAWebSocket()

CFxNAWebSocket::~CFxNAWebSocket ( )

Destructor

Member Function Documentation

◆ close()

void CFxNAWebSocket::close ( CFxNAWebSocketProtocol::CloseCode  closeCode = CFxNAWebSocketProtocol::CloseCodeNormal,
const CFxNAString reason = CFxNAString() 
)

Gracefully closes the socket with the given closeCode and reason.

Parameters
closeCodeInput
reasonInput

◆ connected()

CFxUISignal< void( void ) >& CFxNAWebSocket::connected ( )

Signal is emitted when a connection is successfully established. A connection is successfully established when the socket is connected and the handshake was successful.

◆ disconnected()

CFxUISignal< void( void ) >& CFxNAWebSocket::disconnected ( )

Signal is emitted when the socket is disconnected.

◆ error()

CFxUISignal< void( int ) >& CFxNAWebSocket::error ( )

Signal is emitted after an error occurred. The error parameter describes the type of error that occurred.

◆ open()

void CFxNAWebSocket::open ( const CFxNANetworkRequest request)

Opens a WebSocket connection using the given request.

Parameters
requestInput

◆ sendTextMessage()

long long CFxNAWebSocket::sendTextMessage ( const CFxUIString textMessage)

Sends a text message through the open socket.

Parameters
textMessageText message
Returns
Number of sent bytes.

◆ textMessageReceived()

CFxUISignal< void( const CFxNAString & ) >& CFxNAWebSocket::textMessageReceived ( )

Signal is emitted whenever a text message is received. The message contains the received text.


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