UnrealVoxta 0.1.1
 
Loading...
Searching...
No Matches
AudioWebSocket Class Reference

AudioWebSocket Main low level API to communicate with the audio streaming socket of VoxtaServer. More...

#include <AudioWebSocket.h>

Inheritance diagram for AudioWebSocket:

Public Member Functions

 AudioWebSocket (const FString &serverIP, uint16 serverPort)
 Register the address and port the socket should use to connect with VoxtaServer.
 
 ~AudioWebSocket ()
 
bool Connect (const FGuid &sessionId)
 Create the websocket through FWebSocketsModule and start up the connection.
 
void Close (int code=1000, const FString &reason=FString())
 Manually close the websocket connection.
 
void Send (const void *buffer, unsigned int nBufferBytes)
 Send binary data through the websocket.
 
void Send (const FString &message)
 Send string data through the websocket.
 

Public Attributes

IWebSocket::FWebSocketConnectedEvent OnConnectedEvent
 Called when a web socket connection has been established successfully.
 
IWebSocket::FWebSocketConnectionErrorEvent OnConnectionErrorEvent
 Called when a web socket connection could not be established.
 
IWebSocket::FWebSocketClosedEvent OnClosedEvent
 Called when a web socket connection has been closed.
 

Detailed Description

AudioWebSocket Main low level API to communicate with the audio streaming socket of VoxtaServer.

Internally relies on Unreal's FWebSocketsModule implementation.

Note: This class is not thread-safe. All methods should be called from the same thread.

Constructor & Destructor Documentation

◆ AudioWebSocket()

AudioWebSocket::AudioWebSocket ( const FString & serverIP,
uint16 serverPort )

Register the address and port the socket should use to connect with VoxtaServer.

Parameters
serverIPThe VoxtaServer host IP address. (ipv4)
serverPortThe VoxtaServer host port.

◆ ~AudioWebSocket()

AudioWebSocket::~AudioWebSocket ( )

Member Function Documentation

◆ Close()

void AudioWebSocket::Close ( int code = 1000,
const FString & reason = FString() )

Manually close the websocket connection.

Parameters
codelws_close_status code of the libwebsockets for the closure. 1000 is normal. (https://libwebsockets.org/lws-api-doc-main/html/group__wsclose.html)
reasonHuman readable string explaining why the connection is closing.

◆ Connect()

bool AudioWebSocket::Connect ( const FGuid & sessionId)

Create the websocket through FWebSocketsModule and start up the connection.

Call this after setting up event handlers or to reconnect after connection errors.

Parameters
sessionIdThe sessionId that we want to forward our audio to.
Returns
False if we failed to create the websocket instance.

◆ Send() [1/2]

void AudioWebSocket::Send ( const FString & message)

Send string data through the websocket.

Parameters
messageData to be sent as a UTF-8 encoded string.

◆ Send() [2/2]

void AudioWebSocket::Send ( const void * buffer,
unsigned int nBufferBytes )

Send binary data through the websocket.

Parameters
bufferA pointer to the first byte of the data to be sent.
nBufferBytesNumber of bytes to send.

Member Data Documentation

◆ OnClosedEvent

IWebSocket::FWebSocketClosedEvent AudioWebSocket::OnClosedEvent

Called when a web socket connection has been closed.

◆ OnConnectedEvent

IWebSocket::FWebSocketConnectedEvent AudioWebSocket::OnConnectedEvent

Called when a web socket connection has been established successfully.

◆ OnConnectionErrorEvent

IWebSocket::FWebSocketConnectionErrorEvent AudioWebSocket::OnConnectionErrorEvent

Called when a web socket connection could not be established.


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