UnrealVoxta 0.1.1
 
Loading...
Searching...
No Matches
AudioWebSocket.h
Go to the documentation of this file.
1// Copyright(c) 2024 grrimgrriefer & DZnnah, see LICENSE for details.
2
3#pragma once
4
5#include "CoreMinimal.h"
6#include "IWebSocket.h"
7
15class VOXTAAUDIOUTILITY_API AudioWebSocket : public TSharedFromThis<AudioWebSocket>
16{
17#pragma region events
18public:
20 IWebSocket::FWebSocketConnectedEvent OnConnectedEvent;
21
23 IWebSocket::FWebSocketConnectionErrorEvent OnConnectionErrorEvent;
24
26 IWebSocket::FWebSocketClosedEvent OnClosedEvent;
27#pragma endregion
28
29#pragma region public API
30public:
37 AudioWebSocket(const FString& serverIP, uint16 serverPort);
38
40
49 bool Connect(const FGuid& sessionId);
50
58 void Close(int code = 1000, const FString& reason = FString());
59
66 void Send(const void* buffer, unsigned int nBufferBytes);
67
73 void Send(const FString& message);
74#pragma endregion
75
76#pragma region data
77private:
78 TSharedPtr<IWebSocket> m_socketConnection;
79 FString m_serverIP;
80 uint16 m_serverPort;
81 FGuid m_sessionId;
82#pragma endregion
83};
@ Close
Definition MessageType.h:41
IWebSocket::FWebSocketClosedEvent OnClosedEvent
Called when a web socket connection has been closed.
Definition AudioWebSocket.h:26
bool Connect(const FGuid &sessionId)
Create the websocket through FWebSocketsModule and start up the connection.
Definition AudioWebSocket.cpp:22
void Send(const void *buffer, unsigned int nBufferBytes)
Send binary data through the websocket.
Definition AudioWebSocket.cpp:107
IWebSocket::FWebSocketConnectedEvent OnConnectedEvent
Called when a web socket connection has been established successfully.
Definition AudioWebSocket.h:20
AudioWebSocket(const FString &serverIP, uint16 serverPort)
Register the address and port the socket should use to connect with VoxtaServer.
Definition AudioWebSocket.cpp:9
IWebSocket::FWebSocketConnectionErrorEvent OnConnectionErrorEvent
Called when a web socket connection could not be established.
Definition AudioWebSocket.h:23