Internet Protocol
Unreal Engine Plugin

Websocket Client

How to use Websocket client class

References

#include "websocket/wsclient.h"

How to use

Blueprint: search by GetInternetProtocolSubsystem and call CreateWebsocketClient function

C++: Use the code bellow

#include "websocket/wsclient.h"

UWSClient* client = NewObject<UWSClient>();

Variables

Handshake

  • Set/Get handshake headers.
Handshake
Output pin

Functions

Functions

Is Open

  • Return true if socket is open.
𝑓
Is Open
Return Value
Output pin

Local Endpoint

  • Get the local endpoint of the socket. Use this function only after open connection.
𝑓
Local Endpoint
Return Value
Output pin

Remote Endpoint

  • Get the remote endpoint of the socket. Use this function only after open connection.
𝑓
Remote Endpoint
Return Value
Output pin

Get Error Code

  • Return a struct of the latest error code returned by asio.
𝑓
Get Error Code
Return Value
Output pin

Write

  • Sends string data on the socket.
  • It returns false if socket is closed or if buffer is empty.
𝑓
Write
Target is WSClient
Input pin
Input pin
Target
Input pin
Message
Input pin
Callback
Output pin
Return Value
Output pin
On Message Sent
Custom Event
Output pin
Error Code
Output pin
Bytes Sent
Output pin

Write Buffer

  • Sends buffer data on the socket.
  • It returns false if socket is closed or if buffer is empty.
𝑓
Write Buffer
Target is WSClient
Input pin
Input pin
Target
Input pin
Buffer
Input pin
Callback
Output pin
Return Value
Output pin
On Message Sent
Custom Event
Output pin
Error Code
Output pin
Bytes Sent
Output pin

Ping

  • Send a ping message.
  • It returns false if socket is closed or if buffer is empty.
𝑓
Ping
Target is WSClient
Input pin
Input pin
Target
Input pin
Callback
Output pin
Return Value
Output pin
On Message Sent
Custom Event
Output pin
Error Code
Output pin
Bytes Sent
Output pin

Pong

  • Send a pong message.
  • It returns false if socket is closed or if buffer is empty.
𝑓
Pong
Target is WSClient
Input pin
Input pin
Target
Input pin
Callback
Output pin
Return Value
Output pin
On Message Sent
Custom Event
Output pin
Error Code
Output pin
Bytes Sent
Output pin

Connect

  • Listen for datagram messages on a named port and address.
  • It returns false if socket is already open or if asio return any error code during the bind.
𝑓
Connect
Target is WSClient
Input pin
Input pin
Target
Input pin
Bind Opts
Output pin
Return Value
Output pin

End

  • Perform a smooth close of socket following ws protocol and stop listening for data on it. 'on_close' event will be triggered.
𝑓
End
Target is WSClient
Input pin
Input pin
Target
Input pin
Code
Input pin
Reason
Output pin

Close

  • Close the underlying socket and stop listening for data on it. 'on_close' event will be triggered.
𝑓
Close
Target is WSClient
Input pin
Input pin
Target
Input pin
Code
Input pin
Reason
Output pin

Events

On Connected

  • Event triggered when a connection is estabilished.
Bind Event to On Connected
Input pin
Input pin
Target
Input pin
Event
Output pin
On Connected
Custom Event
Output pin
Handshake
Output pin

On Unexpected Handshake

  • Event triggered when a connection is estabilished.
Bind Event to On Unexpected Handshake
Input pin
Input pin
Target
Input pin
Event
Output pin
On Unexpected Handshake
Custom Event
Output pin
Handshake
Output pin

On Message

  • Event triggered when socket send or receive data.
Bind Event to On Message
Input pin
Input pin
Target
Input pin
Event
Output pin
On Message
Custom Event
Output pin
Buffer
Output pin
Is Binary
Output pin

On Ping

  • This event will be triggered when a ping has been received.
Bind Event to On Ping
Input pin
Input pin
Target
Input pin
Event
Output pin
On Ping
Custom Event
Output pin

On Pong

  • This event will be triggered when a pong has been received.
Bind Event to On Pong
Input pin
Input pin
Target
Input pin
Event
Output pin
On Pong
Custom Event
Output pin

On Close

  • Event triggered when socket is closed.
Bind Event to On Close
Input pin
Input pin
Target
Input pin
Event
Output pin
On Close
Custom Event
Output pin
Code
Output pin
Reason
Output pin

On Error

  • Event triggered if any error occur during async process.
Bind Event to On Error
Input pin
Input pin
Target
Input pin
Event
Output pin
On Error
Custom Event
Output pin
Error Code
Output pin