NAP
Public Member Functions | List of all members
WebSocketMessage Class Referencefinal

#include <websocketmessage.h>

Public Member Functions

 WebSocketMessage (const std::string &message, EWebSocketOPCode code, bool fin=true)
 
 WebSocketMessage (std::string &&message, EWebSocketOPCode code, bool fin=true)
 
 WebSocketMessage ()=delete
 
 WebSocketMessage (WebSocketMessage &&other)
 
WebSocketMessageoperator= (WebSocketMessage &&other)
 
 WebSocketMessage (const WebSocketMessage &other)=default
 
WebSocketMessageoperator= (const WebSocketMessage &other)=default
 
const std::string & getPayload () const
 
void appendPayload (const std::string &payload)
 
EWebSocketOPCode getCode () const
 
bool getFin () const
 

Description

A web-socket message that is received by an end-point or sent to an end-point. Use the various constructors to construct your own message. The message can be sent using a nap::WebSocketClient or nap::WebSocketServer.

Constructor & Destructor Documentation

◆ WebSocketMessage() [1/5]

WebSocketMessage ( const std::string &  message,
EWebSocketOPCode  code,
bool  fin = true 
)

Construct a new web socket message using the given payload, opcode and finalize bit flag.

Parameters
messagethe payload associated with this message.
codethe op code that describes the intent of this message
finif this is the final message

◆ WebSocketMessage() [2/5]

WebSocketMessage ( std::string &&  message,
EWebSocketOPCode  code,
bool  fin = true 
)

Construct a new web socket message using the given payload, opcode and finalize bit flag.

Parameters
messagethe payload associated with this message.
codethe op code that describes the intent of this message
finif this is the final message

◆ WebSocketMessage() [3/5]

WebSocketMessage ( )
delete

◆ WebSocketMessage() [4/5]

◆ WebSocketMessage() [5/5]

WebSocketMessage ( const WebSocketMessage other)
default

Member Function Documentation

◆ appendPayload()

void appendPayload ( const std::string &  payload)

Adds an extra set of characters to the already existing message.

Parameters
payloadthe data to append.

◆ getCode()

EWebSocketOPCode getCode ( ) const
Returns
the message opcode that describes the purpose of this message.

◆ getFin()

bool getFin ( ) const

A message with the fin bit set will be sent as the last message of its sequence. A message with the fin bit cleared will require subsequent frames of opcode continuation until one of them has the fin bit set.

Returns
if the fin (final) bit is set

◆ getPayload()

const std::string& getPayload ( ) const
Returns
a reference to the message's payload string

◆ operator=() [1/2]

WebSocketMessage& operator= ( const WebSocketMessage other)
default

◆ operator=() [2/2]

WebSocketMessage& operator= ( WebSocketMessage &&  other)