Unreal Engine Plugin
Websocket Server
How to use Websocket server class
References
#include "WS/WSServer.h"
How to use
Blueprint: search by GetInternetProtocolSubsystem
and call CreateWebsocketServer
function
C++: Use the code bellow
Functions
Set Socket
- Set
protocol
,port
,max connected clients
of socket
Get Acceptor
- Get acceptor properties
Get Sockets
- Get all connected sockets properties
Set Max Send Buffer Size
- Set max size in bytes of send buffer
Get Max Send Buffer Size
- Get max size in bytes of send buffer
Set Split Package
- If the size of a message exceeds the maximum allowed size for the send buffer, it will be divided into smaller packets before being sent.
Get Split Package
- Get if Split Package is enabled
Send Handshake To
- Send a handshake to a specific socket
- Return false if socket is closed or string is empty
- Warning: You must call this function if you assign event
OnSocketAccepted
Send Handshake Error To
- Send a handshake to a specific socket and close connection after message has been sent
- Return false if socket is closed or string is empty
- Warning: You must call this function to rejectosocket if you assign event
OnSocketAccepted
Send Str To
- Send a string message to a specific socket
- Return false if socket is closed or string is empty
- Warning: If you’re using Windows, ensure that you are sending characters compatible with UTF-8
Send Buffer To
- Send a buffer message to a specific socket
- Return false if socket is closed or buffer is empty
Send Ping To
- Send a ping to a specific socket
- Return false if socket is closed
Open
- Open socket
- Return false if its already open
Close
- Close connection
Disconnect Socket
- Close connection of specific socket
Get Error Code
- Get latest error code
Handshake Functions
Handshake is a http request to contact the server and requesting a WebSocket connection
Set Headers
- Set handshake request headers
Get Header
- Get reference to handshake request headers
- Use this function to append or modify headers
Dataframe Functions
Set RSV1

Use RSV1

Set RSV2

Use RSV2

Set RSV3

Use RSV3

Set Mask

Use Mask

Events
On Socket Accepted
- Event triggered when a new client connection is estabilished
Send Handshake To
orSend Handshake Error To
must be called if this event has been assigned
On Bytes Transfered
- Event triggered when socket sent and receive data
On Message Sent
- Event triggered when a message is sent to a specific socket
On Message Received
- Event triggered when a message is received
On Pong Received
- Event triggered when a pong message is received
On Close Notify
- Event triggered when a client send a close notification
On Close
- Event triggered when all sockets are disconnected and server is closed
On Socket Disconnected
- Event triggered when a socket is disconnected
On Error
- Event triggered if any error occur during async process