Internet Protocol
Unreal Engine Plugin

Websocket Client

How to use Websocket client class

References

#include "WS/WSClient.h"

How to use

Blueprint: search by GetInternetProtocolSubsystem and call CreateWebsocketClient function

C++: Use the code bellow

#include "Websockets/WebsocketClient.h"
 
UWSClient* WSClient = NewObject<UWSClient>();

Functions

Set Host

  • Set the adress and port of host WS client

Get Socket

  • Get socket properties WS client

Set Max Send Buffer Size

  • Set max size in bytes of send buffer WS client

Get Max Send Buffer Size

  • Get max size in bytes of send buffer WS client

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. WS client

Get Split Package

  • Get if Split Package is enabled WS client

Send Str

  • Send a string message
  • 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 WS client

Send Buffer

  • Send a buffer message
  • Return false if socket is closed or buffer is empty WS client

Send Ping

  • Send a ping to websocket server
  • Return false if socket is closed WS client

Connect

  • Connect to the host
  • Return false if its already open WS client

Close

  • Close connection WS client

Get Error Code

  • Get latest error code WS client

Handshake Functions

Handshake is a http request to contact the server and requesting a WebSocket connection

Set Headers

  • Set handshake request headers WS client

Get Header

  • Get reference to handshake request headers
  • Use this function to append or modify headers WS client

Dataframe Functions

Set RSV1

WS client

Use RSV1

WS client

Set RSV2

WS client

Use RSV2

WS client

Set RSV3

WS client

Use RSV3

WS client

Set Mask

WS client

Use Mask

WS client

Events

On Connected

  • Event triggered when a connection is estabilished WS client

On Bytes Transfered

  • Event triggered when socket sent and receive data WS client

On Message Sent

  • Event triggered when a message is sent WS client

On Message Received

  • Event triggered when a message is received WS client

On Pong Received

  • Event triggered when a pong message is received WS client

On Close Notify

  • Event triggered when a server send a close notification WS client

On Close

  • Event triggered when a connection is closed WS client

On Handshke Fail

  • Event triggered if any error occur during handshake.
  • Normally, when a handshake error occurs, the socket is automatically closed, triggering the on_close event. WS client

On Error

  • Event triggered if any error occur during async process WS client