MetaSoul

Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
FESIONative Class Reference

`#include <ESIONative.h>`

## Public Member Functions
| FESIONative (const bool bForceTLSMode=false, const bool bShouldVerifyTLSCertificate=false)
void | Connect (const FString &InAddressAndPort)
void | Connect (const FEmoShapeConnectParams &ConnectParams)
void | JoinNamespace (const FString &Namespace)
void | LeaveNamespace (const FString &Namespace)
void | Disconnect ()
void | SyncDisconnect ()
void | ClearAllCallbacks ()
void | Emit (const FString &EventName, const TSharedPtr< FJsonValue > &Message=nullptr, TFunction< void(const TArray< TSharedPtr< FJsonValue > > &)> CallbackFunction=nullptr, const FString &Namespace=TEXT("/"))
void | Emit (const FString &EventName, const TSharedPtr< FJsonObject > &ObjectMessage=nullptr, TFunction< void(const TArray< TSharedPtr< FJsonValue > > &)> CallbackFunction=nullptr, const FString &Namespace=TEXT("/"))
void | Emit (const FString &EventName, const FString &StringMessage=FString(), TFunction< void(const TArray< TSharedPtr< FJsonValue > > &)> CallbackFunction=nullptr, const FString &Namespace=TEXT("/"))
void | Emit (const FString &EventName, const SIO_TEXT_TYPE StringMessage=TEXT(""), TFunction< void(const TArray< TSharedPtr< FJsonValue > > &)> CallbackFunction=nullptr, const FString &Namespace=TEXT("/"))
void | Emit (const FString &EventName, double NumberMessage, TFunction< void(const TArray< TSharedPtr< FJsonValue > > &)> CallbackFunction=nullptr, const FString &Namespace=TEXT("/"))
void | Emit (const FString &EventName, bool BooleanMessage, TFunction< void(const TArray< TSharedPtr< FJsonValue > > &)> CallbackFunction=nullptr, const FString &Namespace=TEXT("/"))
void | Emit (const FString &EventName, const TArray< uint8 > &BinaryMessage, TFunction< void(const TArray< TSharedPtr< FJsonValue > > &)> CallbackFunction=nullptr, const FString &Namespace=TEXT("/"))
void | Emit (const FString &EventName, const TArray< TSharedPtr< FJsonValue > > &ArrayMessage, TFunction< void(const TArray< TSharedPtr< FJsonValue > > &)> CallbackFunction=nullptr, const FString &Namespace=TEXT("/"))
void | Emit (const FString &EventName, UStruct *Struct, const void *StructPtr, TFunction< void(const TArray< TSharedPtr< FJsonValue > > &)> CallbackFunction=nullptr, const FString &Namespace=TEXT("/"))
void | Emit (const FString &EventName, TFunction< void(const TArray< TSharedPtr< FJsonValue > > &)> CallbackFunction=nullptr, const FString &Namespace=TEXT("/"))
void | EmitRaw (const FString &EventName, const emoshapeio::message::list &MessageList=nullptr, TFunction< void(const emoshapeio::message::list &)> CallbackFunction=nullptr, const FString &Namespace=TEXT("/"))
void | EmitRawBinary (const FString &EventName, uint8 *Data, int32 DataLength, const FString &Namespace=TEXT("/"))
void | OnEvent (const FString &EventName, TFunction< void(const FString &, const TSharedPtr< FJsonValue > &)> CallbackFunction, const FString &Namespace=TEXT("/"), EEmoShapeIOThreadOverrideOption CallbackThread=USE_DEFAULT)
void | OnRawEvent (const FString &EventName, TFunction< void(const FString &, const emoshapeio::message::ptr &)> CallbackFunction, const FString &Namespace=TEXT("/"), EEmoShapeIOThreadOverrideOption CallbackThread=USE_DEFAULT)
void | OnRawBinaryEvent (const FString &EventName, TFunction< void(const FString &, const TArray< uint8 > &)> CallbackFunction, const FString &Namespace=TEXT("/"))
void | UnbindEvent (const FString &EventName, const FString &Namespace=TEXT("/"))

## Public Attributes
TFunction< void(const FString &SessionId) | OnConnectedCallback )
TFunction< void(const EEmoShapeIOConnectionCloseReason Reason)> | OnDisconnectedCallback
TFunction< void(const FString &Namespace) | OnNamespaceConnectedCallback )
TFunction< void(const FString &Namespace) | OnNamespaceDisconnectedCallback )
TFunction< void(const uint32 AttemptCount, const uint32 DelayInMs)> | OnReconnectionCallback
TFunction< void()> | OnFailCallback
TMap< FString, FEmoShapeIOBoundEvent > | EventFunctionMap
FEmoShapeConnectParams | URLParams
uint32 | MaxReconnectionAttempts
uint32 | ReconnectionDelay
bool | bIsConnected
FString | SessionId
FString | LastSessionId
bool | VerboseLog
bool | bCallbackOnGameThread
bool | bIsSetupForTLS
bool | bForceTLSUse
bool | bUsingTLSCertVerification
bool | bUnbindEventsOnDisconnect

## Protected Member Functions
void | ClearInternalCallbacks ()
void | SetupInternalCallbacks ()
void | RebindCurrentEventMap ()
bool | IsTLSURL (const FString &URL)
void | SyncPrivateClientToTLSMode (const FString &URL)
void | InitPrivateClient (const bool bShouldUseTlsLibraries=false, const bool bShouldVerifyTLSCertificate=false)

## Protected Attributes
TSharedPtr< emoshapeio::client > | PrivateClient

## Constructor & Destructor Documentation

## ◆ FESIONative()

FESIONative::FESIONative | ( | const bool | bForceTLSMode = false,
|  | const bool | bShouldVerifyTLSCertificate = false )

By default TLS verification is off. TLS mode will be set by URL on connect.

## Member Function Documentation

## ◆ ClearAllCallbacks()

void FESIONative::ClearAllCallbacks | ( |  | ) |

## ◆ ClearInternalCallbacks()

void FESIONative::ClearInternalCallbacks | ( |  | ) |
| protected

On disconnect or mode change bound events become invalid

## ◆ Connect() [1/2]

void FESIONative::Connect | ( | const FEmoShapeConnectParams & | ConnectParams | ) |

Connect to a socket.io server, optional method if auto-connect is set to true. Query and headers are defined by a {'stringKey':'stringValue'} EmoShapeJson Object

Parameters

  AddressAndPort | the address in URL format with port
  Query | http query as a EmoShapeJsonObject with string keys and values
  Headers | http header as a EmoShapeJsonObject with string keys and values

## ◆ Connect() [2/2]

void FESIONative::Connect | ( | const FString & | InAddressAndPort | ) |

Connect to a socket.io server, optional method if auto-connect is set to true. Overloaded function where you don't care about query and headers

Parameters

  AddressAndPort | the address in URL format with port

## ◆ Disconnect()

void FESIONative::Disconnect | ( |  | ) |

Disconnect from current socket.io server, optional method.

Parameters

  AddressAndPort | the address in URL format with port

## ◆ Emit() [1/10]

void FESIONative::Emit | ( | const FString & | EventName,
|  | bool | BooleanMessage,
|  | TFunction< void(const TArray< TSharedPtr< FJsonValue > > &)> | CallbackFunction = nullptr,
|  | const FString & | Namespace = TEXT("/") )

(Overloaded) Emit an event with a bool message

Parameters

  EventName | Event name
  BooleanMessage | Message in bool format
  CallbackFunction | Optional callback TFunction
  Namespace | Optional Namespace within socket.io

## ◆ Emit() [2/10]

void FESIONative::Emit | ( | const FString & | EventName,
|  | const FString & | StringMessage = FString(),
|  | TFunction< void(const TArray< TSharedPtr< FJsonValue > > &)> | CallbackFunction = nullptr,
|  | const FString & | Namespace = TEXT("/") )

(Overloaded) Emit an event with a string message

Parameters

  EventName | Event name
  StringMessage | Message in string format
  CallbackFunction | Optional callback TFunction
  Namespace | Optional Namespace within socket.io

## ◆ Emit() [3/10]

void FESIONative::Emit | ( | const FString & | EventName,
|  | const SIO_TEXT_TYPE | StringMessage = TEXT(""),
|  | TFunction< void(const TArray< TSharedPtr< FJsonValue > > &)> | CallbackFunction = nullptr,
|  | const FString & | Namespace = TEXT("/") )

(Overloaded) Emit an event with a string literal message

Parameters

  EventName | Event name
  StringMessage | Message in string format
  CallbackFunction | Optional callback TFunction
  Namespace | Optional Namespace within socket.io

## ◆ Emit() [4/10]

void FESIONative::Emit | ( | const FString & | EventName,
|  | const TArray< TSharedPtr< FJsonValue > > & | ArrayMessage,
|  | TFunction< void(const TArray< TSharedPtr< FJsonValue > > &)> | CallbackFunction = nullptr,
|  | const FString & | Namespace = TEXT("/") )

(Overloaded) Emit an event with an array message

Parameters

  EventName | Event name
  ArrayMessage | Message in an TArray of FJsonValues
  CallbackFunction | Optional callback TFunction
  Namespace | Optional Namespace within socket.io

## ◆ Emit() [5/10]

void FESIONative::Emit | ( | const FString & | EventName,
|  | const TArray< uint8 > & | BinaryMessage,
|  | TFunction< void(const TArray< TSharedPtr< FJsonValue > > &)> | CallbackFunction = nullptr,
|  | const FString & | Namespace = TEXT("/") )

(Overloaded) Emit an event with a binary message

Parameters

  EventName | Event name
  BinaryMessage | Message in an TArray of uint8
  CallbackFunction | Optional callback TFunction
  Namespace | Optional Namespace within socket.io

## ◆ Emit() [6/10]

void FESIONative::Emit | ( | const FString & | EventName,
|  | const TSharedPtr< FJsonObject > & | ObjectMessage = nullptr,
|  | TFunction< void(const TArray< TSharedPtr< FJsonValue > > &)> | CallbackFunction = nullptr,
|  | const FString & | Namespace = TEXT("/") )

(Overloaded) Emit an event with a Json Object message

Parameters

  EventName | Event name
  ObjectMessage | FJsonObject
  CallbackFunction | Optional callback TFunction
  Namespace | Optional Namespace within socket.io

## ◆ Emit() [7/10]

void FESIONative::Emit | ( | const FString & | EventName,
|  | const TSharedPtr< FJsonValue > & | Message = nullptr,
|  | TFunction< void(const TArray< TSharedPtr< FJsonValue > > &)> | CallbackFunction = nullptr,
|  | const FString & | Namespace = TEXT("/") )

Emit an event with a JsonValue message

Parameters

  EventName | Event name
  Message | FJsonValue
  CallbackFunction | Optional callback TFunction
  Namespace | Optional Namespace within socket.io

## ◆ Emit() [8/10]

void FESIONative::Emit | ( | const FString & | EventName,
|  | double | NumberMessage,
|  | TFunction< void(const TArray< TSharedPtr< FJsonValue > > &)> | CallbackFunction = nullptr,
|  | const FString & | Namespace = TEXT("/") )

(Overloaded) Emit an event with a number (double) message

Parameters

  EventName | Event name
  NumberMessage | Message in double format
  CallbackFunction | Optional callback TFunction
  Namespace | Optional Namespace within socket.io

## ◆ Emit() [9/10]

void FESIONative::Emit | ( | const FString & | EventName,
|  | TFunction< void(const TArray< TSharedPtr< FJsonValue > > &)> | CallbackFunction = nullptr,
|  | const FString & | Namespace = TEXT("/") )

(Overloaded) Emit an event without a message

Parameters

  EventName | Event name
  Struct | UStruct type usually obtained via e.g. FMyStructType::StaticStruct()
  StructPtr | Pointer to the actual struct memory e.g. &MyStruct
  CallbackFunction | Optional callback TFunction
  Namespace | Optional Namespace within socket.io

## ◆ Emit() [10/10]

void FESIONative::Emit | ( | const FString & | EventName,
|  | UStruct * | Struct,
|  | const void * | StructPtr,
|  | TFunction< void(const TArray< TSharedPtr< FJsonValue > > &)> | CallbackFunction = nullptr,
|  | const FString & | Namespace = TEXT("/") )

(Overloaded) Emit an event with an UStruct message

Parameters

  EventName | Event name
  Struct | UStruct type usually obtained via e.g. FMyStructType::StaticStruct()
  StructPtr | Pointer to the actual struct memory e.g. &MyStruct
  CallbackFunction | Optional callback TFunction
  Namespace | Optional Namespace within socket.io

## ◆ EmitRaw()

void FESIONative::EmitRaw | ( | const FString & | EventName,
|  | const emoshapeio::message::list & | MessageList = nullptr,
|  | TFunction< void(const emoshapeio::message::list &)> | CallbackFunction = nullptr,
|  | const FString & | Namespace = TEXT("/") )

Emit a raw emoshapeio::message event

Parameters

  EventName | Event name
  MessageList | Message in sio::message::list format
  CallbackFunction | Optional callback TFunction with raw signature
  Namespace | Optional Namespace within socket.io

## ◆ EmitRawBinary()

void FESIONative::EmitRawBinary | ( | const FString & | EventName,
|  | uint8 * | Data,
|  | int32 | DataLength,
|  | const FString & | Namespace = TEXT("/") )

Emit an optimized binary message

Parameters

  EventName | Event name
  Data | Buffer Pointer
  DataLength | Buffer size
  Namespace | Optional Namespace within socket.io

## ◆ InitPrivateClient()

void FESIONative::InitPrivateClient | ( | const bool | bShouldUseTlsLibraries = false,
|  | const bool | bShouldVerifyTLSCertificate = false )
| protected

## ◆ IsTLSURL()

bool FESIONative::IsTLSURL | ( | const FString & | URL | ) |
| protected

Checks for https prepend

## ◆ JoinNamespace()

void FESIONative::JoinNamespace | ( | const FString & | Namespace | ) |

Join a desired namespace. Keep in mind that emitting to a namespace will auto-join it

## ◆ LeaveNamespace()

void FESIONative::LeaveNamespace | ( | const FString & | Namespace | ) |

Leave a specified namespace.

## ◆ OnEvent()

void FESIONative::OnEvent | ( | const FString & | EventName,
|  | TFunction< void(const FString &, const TSharedPtr< FJsonValue > &)> | CallbackFunction,
|  | const FString & | Namespace = TEXT("/"),
|  | EEmoShapeIOThreadOverrideOption | CallbackThread = USE_DEFAULT )

Call function callback on receiving socket event. C++ only.

Parameters

  EventName | Event name
  TFunction | Lambda callback, JSONValue
  Namespace | Optional namespace, defaults to default namespace
  CallbackThread | Override default bCallbackOnGameThread option to specified option for this event

## ◆ OnRawBinaryEvent()

void FESIONative::OnRawBinaryEvent | ( | const FString & | EventName,
|  | TFunction< void(const FString &, const TArray< uint8 > &)> | CallbackFunction,
|  | const FString & | Namespace = TEXT("/") )

Call function callback on receiving binary event. C++ only. NB: Does not get added to FEmoShapeIONative event map (use OnEvent)!

Parameters

  EventName | Event name
  TFunction | Lambda callback, raw flavor
  Namespace | Optional namespace, defaults to default namespace

## ◆ OnRawEvent()

void FESIONative::OnRawEvent | ( | const FString & | EventName,
|  | TFunction< void(const FString &, const emoshapeio::message::ptr &)> | CallbackFunction,
|  | const FString & | Namespace = TEXT("/"),
|  | EEmoShapeIOThreadOverrideOption | CallbackThread = USE_DEFAULT )

Call function callback on receiving raw event. C++ only. NB: Does not get added to FEmoShapeIONative event map (use OnEvent)!

Parameters

  EventName | Event name
  TFunction | Lambda callback, raw flavor
  Namespace | Optional namespace, defaults to default namespace
  CallbackThread | Override default bCallbackOnGameThread option to specified option for this event

## ◆ RebindCurrentEventMap()

void FESIONative::RebindCurrentEventMap | ( |  | ) |
| protected

## ◆ SetupInternalCallbacks()

void FESIONative::SetupInternalCallbacks | ( |  | ) |
| protected

Linkup PrivateClient callbacks to FEmoShapeIONative

## ◆ SyncDisconnect()

void FESIONative::SyncDisconnect | ( |  | ) |

## ◆ SyncPrivateClientToTLSMode()

void FESIONative::SyncPrivateClientToTLSMode | ( | const FString & | URL | ) |
| protected

If non-matching mode, this will:

- close the connection
- clear and re-link internal callbacks
- re-construct PrivateClient in the correct mode NB: URL preference overwritten if bForceTLSUse is true

## ◆ UnbindEvent()

void FESIONative::UnbindEvent | ( | const FString & | EventName,
|  | const FString & | Namespace = TEXT("/") )

Unbinds currently bound callback from given event.

Parameters

  EventName | Event name

## Member Data Documentation

## ◆ bCallbackOnGameThread

bool FESIONative::bCallbackOnGameThread

If true, all callbacks and events will occur on game thread. Default true.

## ◆ bForceTLSUse

bool FESIONative::bForceTLSUse

If at initialization forcing is set true, it will use TLS despite URL used

## ◆ bIsConnected

bool FESIONative::bIsConnected

Whether this instance has a currently live connection to the server.

## ◆ bIsSetupForTLS

bool FESIONative::bIsSetupForTLS

Set true if connection currently configured for TLS

## ◆ bUnbindEventsOnDisconnect

bool FESIONative::bUnbindEventsOnDisconnect

If true all events are unbound on disconnect

## ◆ bUsingTLSCertVerification

bool FESIONative::bUsingTLSCertVerification

If true will attempt to verify certificate (NB: this currently doesn't work)

## ◆ EventFunctionMap

TMap<FString, FEmoShapeIOBoundEvent> FESIONative::EventFunctionMap

## ◆ LastSessionId

FString FESIONative::LastSessionId

## ◆ MaxReconnectionAttempts

uint32 FESIONative::MaxReconnectionAttempts

The number of attempts before giving up. 0 = infinity. Set before connecting

## ◆ OnConnectedCallback

TFunction<void(const FString& SessionId) FESIONative::OnConnectedCallback)

## ◆ OnDisconnectedCallback

TFunction<void(const EEmoShapeIOConnectionCloseReason Reason)> FESIONative::OnDisconnectedCallback

## ◆ OnFailCallback

TFunction<void()> FESIONative::OnFailCallback

## ◆ OnNamespaceConnectedCallback

TFunction<void(const FString& Namespace) FESIONative::OnNamespaceConnectedCallback)

## ◆ OnNamespaceDisconnectedCallback

TFunction<void(const FString& Namespace) FESIONative::OnNamespaceDisconnectedCallback)

## ◆ OnReconnectionCallback

TFunction<void(const uint32 AttemptCount, const uint32 DelayInMs)> FESIONative::OnReconnectionCallback

## ◆ PrivateClient

TSharedPtr<emoshapeio::client> FESIONative::PrivateClient
| protected

## ◆ ReconnectionDelay

uint32 FESIONative::ReconnectionDelay

in milliseconds, default is 5000

## ◆ SessionId

FString FESIONative::SessionId

When connected this session id will be valid and contain a unique Id.

## ◆ URLParams

FEmoShapeConnectParams FESIONative::URLParams

Address& Port, Path, Query & Headers

## ◆ VerboseLog

bool FESIONative::VerboseLog

If set to true, each state change callback will log to console

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

- EmoShapeIOClient/Public/ESIONative.h
- EmoShapeIOClient/Private/ESIONative.cpp