Skip to content

Commit

Permalink
add text() param support for emitnative
Browse files Browse the repository at this point in the history
  • Loading branch information
getnamo committed Aug 1, 2019
1 parent 80774ab commit e7b9c51
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion SocketIOClient.uplugin
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"FileVersion": 3,
"Version": 1,
"VersionName": "1.0.11",
"VersionName": "1.0.12",
"EngineVersion" : "4.22.0",
"FriendlyName": "Socket.IO Client",
"Description": "Real-time networking library Socket.IO Client usable from blueprints and c++.",
Expand Down
5 changes: 5 additions & 0 deletions Source/SocketIOClient/Private/SocketIOClientComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,11 @@ void USocketIOClientComponent::EmitNative(const FString& EventName, UStruct* Str
EmitNative(EventName, USIOJConvert::ToJsonObject(Struct, (void*)StructPtr), CallbackFunction, Namespace);
}

void USocketIOClientComponent::EmitNative(const FString& EventName, const SIO_TEXT_TYPE StringMessage /*= TEXT("")*/, TFunction< void(const TArray<TSharedPtr<FJsonValue>>&)> CallbackFunction /*= nullptr*/, const FString& Namespace /*= FString(TEXT("/"))*/)
{
EmitNative(EventName, MakeShareable(new FJsonValueString(FString(StringMessage))), CallbackFunction, Namespace);
}

#if PLATFORM_WINDOWS
#pragma endregion Emit
#pragma region OnEvents
Expand Down
13 changes: 13 additions & 0 deletions Source/SocketIOClient/Public/SocketIOClientComponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,19 @@ class SOCKETIOCLIENT_API USocketIOClientComponent : public UActorComponent
TFunction< void(const TArray<TSharedPtr<FJsonValue>>&)> CallbackFunction = nullptr,
const FString& Namespace = FString(TEXT("/")));

/**
* (Overloaded) Emit an event with a string message
*
* @param EventName Event name
* @param StringMessage Message in string format
* @param CallbackFunction Optional callback TFunction
* @param Namespace Optional Namespace within socket.io
*/
void EmitNative(const FString& EventName,
const SIO_TEXT_TYPE StringMessage = TEXT(""),
TFunction< void(const TArray<TSharedPtr<FJsonValue>>&)> CallbackFunction = nullptr,
const FString& Namespace = FString(TEXT("/")));

/**
* (Overloaded) Emit an event with a number (double) message
*
Expand Down

0 comments on commit e7b9c51

Please sign in to comment.