Skip to content

Commit

Permalink
5.2 update and extra auth
Browse files Browse the repository at this point in the history
can append more key:value pairs to auth map sent on connect
  • Loading branch information
getnamo committed Jun 26, 2023
1 parent fadf99a commit 64b4360
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
4 changes: 2 additions & 2 deletions SocketIOClient.uplugin
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"FileVersion": 3,
"Version": 1,
"VersionName": "2.5.8",
"EngineVersion": "5.1",
"VersionName": "2.6.0",
"EngineVersion": "5.2",
"FriendlyName": "Socket.IO Client",
"Description": "Real-time WebSocket networking via Socket.IO protocol usable from blueprints and c++.",
"Category": "Networking",
Expand Down
12 changes: 12 additions & 0 deletions Source/SocketIOClient/Private/SocketIONative.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,18 @@ void FSocketIONative::Connect(const FSIOConnectParams& InConnectParams)
{
AuthMessage->get_map()["token"] = sio::string_message::create(USIOMessageConvert::StdString(URLParams.AuthToken));
}
if (URLParams.ExtraAuth.Num() > 0)
{
TArray<FString> Keys;
URLParams.ExtraAuth.GetKeys(Keys);

for (const FString& Key : Keys)
{
std::string StdKey = USIOMessageConvert::StdString(Key);
std::string StdValue = USIOMessageConvert::StdString(URLParams.ExtraAuth[Key]);
AuthMessage->get_map()[StdKey] = sio::string_message::create(StdValue);
}
}

QueryMap = USIOMessageConvert::FStringMapToStdStringMap(URLParams.Query);
HeadersMap = USIOMessageConvert::FStringMapToStdStringMap(URLParams.Headers);
Expand Down
6 changes: 5 additions & 1 deletion Source/SocketIOClient/Public/SIOMessageConvert.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,14 @@ struct SOCKETIOCLIENT_API FSIOConnectParams
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = SocketIOConnectionParams)
TMap<FString, FString> Headers;

/** Optional authorization JSON to send to the server upon initial connection*/
/** Optional authorization auth:{token:""} to send to the server upon initial connection */
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = SocketIOConnectionParams)
FString AuthToken;

/** Optional custom auth key:map pairs added, this is separate from token:"" pair */
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = SocketIOConnectionParams)
TMap<FString, FString> ExtraAuth;

/** Optional path part of URL string. Default is 'socket.io'*/
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = SocketIOConnectionParams)
FString Path;
Expand Down

0 comments on commit 64b4360

Please sign in to comment.