Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/origin/feature-uejson'
Browse files Browse the repository at this point in the history
  • Loading branch information
getnamo committed Nov 27, 2016
2 parents 00fe651 + 0e3b395 commit 3dd5807
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 37 deletions.
Binary file modified Resources/Icon128.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 15 additions & 8 deletions SocketIOClient.uplugin
Original file line number Diff line number Diff line change
@@ -1,31 +1,38 @@
{
"FileVersion": 3,
"Version": 1,
"VersionName": "0.4.0",
"FriendlyName": "SocketIOClient",
"Description": "Socket IO C++ Client ported to UE4",
"VersionName": "0.4.2",
"FriendlyName": "Socket.IO Client",
"Description": "Real-time networking library Socket.IO Client usable from blueprints and c++.",
"Category": "Networking",
"CreatedBy": "UE4 London Meetup",
"CreatedBy": "Getnamo",
"CreatedByURL": "http://getnamo.com",
"DocsURL": "https://github.com/getnamo/socketio-client-ue4",
"MarketplaceURL": "",
"SupportURL": "",
"EnabledByDefault": false,
"CanContainContent": false,
"IsBetaVersion": false,
"Installed": false,
"Modules": [
{
"Name": "SocketIOClient",
"Type": "Runtime",
"LoadingPhase": "Default"
"LoadingPhase": "Default",
"WhitelistPlatforms": [
"Win64",
"Win32"
]
},
{
"Name" : "SIOJson",
"Type" : "Runtime",
"Name": "SIOJson",
"Type": "Runtime",
"LoadingPhase": "PreDefault"
},
{
"Name": "SIOJEditorPlugin",
"Type": "Developer"
"Type": "Developer",
"LoadingPhase": "Default"
}
]
}
2 changes: 1 addition & 1 deletion Source/SIOJson/Private/SIOJLibrary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ TArray<uint8> USIOJLibrary::Conv_JsonValueToBytes(USIOJsonValue* InValue)
return InValue->AsBinary();
}

void USIOJLibrary::CallURL(UObject* WorldContextObject, const FString& URL, ERequestVerb Verb, ERequestContentType ContentType, USIOJsonObject* SIOJJson, const FSIOJCallDelegate& Callback)
void USIOJLibrary::CallURL(UObject* WorldContextObject, const FString& URL, ESIORequestVerb Verb, ESIORequestContentType ContentType, USIOJsonObject* SIOJJson, const FSIOJCallDelegate& Callback)
{
UWorld* World = GEngine->GetWorldFromContextObject(WorldContextObject);
if (World == nullptr)
Expand Down
34 changes: 17 additions & 17 deletions Source/SIOJson/Private/SIOJRequestJSON.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ USIOJRequestJSON::USIOJRequestJSON(const class FObjectInitializer& PCIP)
: Super(PCIP),
BinaryContentType(TEXT("application/octet-stream"))
{
RequestVerb = ERequestVerb::GET;
RequestContentType = ERequestContentType::x_www_form_urlencoded_url;
RequestVerb = ESIORequestVerb::GET;
RequestContentType = ESIORequestContentType::x_www_form_urlencoded_url;

ResetData();
}
Expand All @@ -29,8 +29,8 @@ USIOJRequestJSON* USIOJRequestJSON::ConstructRequest(UObject* WorldContextObject

USIOJRequestJSON* USIOJRequestJSON::ConstructRequestExt(
UObject* WorldContextObject,
ERequestVerb Verb,
ERequestContentType ContentType)
ESIORequestVerb Verb,
ESIORequestContentType ContentType)
{
USIOJRequestJSON* Request = ConstructRequest(WorldContextObject);

Expand All @@ -40,7 +40,7 @@ USIOJRequestJSON* USIOJRequestJSON::ConstructRequestExt(
return Request;
}

void USIOJRequestJSON::SetVerb(ERequestVerb Verb)
void USIOJRequestJSON::SetVerb(ESIORequestVerb Verb)
{
RequestVerb = Verb;
}
Expand All @@ -50,7 +50,7 @@ void USIOJRequestJSON::SetCustomVerb(FString Verb)
CustomVerb = Verb;
}

void USIOJRequestJSON::SetContentType(ERequestContentType ContentType)
void USIOJRequestJSON::SetContentType(ESIORequestContentType ContentType)
{
RequestContentType = ContentType;
}
Expand Down Expand Up @@ -151,9 +151,9 @@ FString USIOJRequestJSON::GetURL()
return HttpRequest->GetURL();
}

ERequestStatus USIOJRequestJSON::GetStatus()
ESIORequestStatus USIOJRequestJSON::GetStatus()
{
return ERequestStatus((uint8)HttpRequest->GetStatus());
return ESIORequestStatus((uint8)HttpRequest->GetStatus());
}

int32 USIOJRequestJSON::GetResponseCode()
Expand Down Expand Up @@ -222,23 +222,23 @@ void USIOJRequestJSON::ProcessRequest()
// Set verb
switch (RequestVerb)
{
case ERequestVerb::GET:
case ESIORequestVerb::GET:
HttpRequest->SetVerb(TEXT("GET"));
break;

case ERequestVerb::POST:
case ESIORequestVerb::POST:
HttpRequest->SetVerb(TEXT("POST"));
break;

case ERequestVerb::PUT:
case ESIORequestVerb::PUT:
HttpRequest->SetVerb(TEXT("PUT"));
break;

case ERequestVerb::DEL:
case ESIORequestVerb::DEL:
HttpRequest->SetVerb(TEXT("DELETE"));
break;

case ERequestVerb::CUSTOM:
case ESIORequestVerb::CUSTOM:
HttpRequest->SetVerb(CustomVerb);
break;

Expand All @@ -249,7 +249,7 @@ void USIOJRequestJSON::ProcessRequest()
// Set content-type
switch (RequestContentType)
{
case ERequestContentType::x_www_form_urlencoded_url:
case ESIORequestContentType::x_www_form_urlencoded_url:
{
HttpRequest->SetHeader(TEXT("Content-Type"), TEXT("application/x-www-form-urlencoded"));

Expand Down Expand Up @@ -278,7 +278,7 @@ void USIOJRequestJSON::ProcessRequest()

break;
}
case ERequestContentType::x_www_form_urlencoded_body:
case ESIORequestContentType::x_www_form_urlencoded_body:
{
HttpRequest->SetHeader(TEXT("Content-Type"), TEXT("application/x-www-form-urlencoded"));

Expand Down Expand Up @@ -307,7 +307,7 @@ void USIOJRequestJSON::ProcessRequest()

break;
}
case ERequestContentType::binary:
case ESIORequestContentType::binary:
{
HttpRequest->SetHeader(TEXT("Content-Type"), BinaryContentType);
HttpRequest->SetContent(RequestBytes);
Expand All @@ -316,7 +316,7 @@ void USIOJRequestJSON::ProcessRequest()

break;
}
case ERequestContentType::json:
case ESIORequestContentType::json:
{
HttpRequest->SetHeader(TEXT("Content-Type"), TEXT("application/json"));

Expand Down
2 changes: 1 addition & 1 deletion Source/SIOJson/Public/SIOJLibrary.h
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ class USIOJLibrary : public UBlueprintFunctionLibrary
public:
/** Easy way to process http requests */
UFUNCTION(BlueprintCallable, Category = "SIOJ|Utility", meta = (WorldContext = "WorldContextObject"))
static void CallURL(UObject* WorldContextObject, const FString& URL, ERequestVerb Verb, ERequestContentType ContentType, USIOJsonObject* SIOJJson, const FSIOJCallDelegate& Callback);
static void CallURL(UObject* WorldContextObject, const FString& URL, ESIORequestVerb Verb, ESIORequestContentType ContentType, USIOJsonObject* SIOJJson, const FSIOJCallDelegate& Callback);

/** Called when URL is processed (one for both success/unsuccess events)*/
static void OnCallComplete(USIOJRequestJSON* Request);
Expand Down
12 changes: 6 additions & 6 deletions Source/SIOJson/Public/SIOJRequestJSON.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,11 @@ class SIOJSON_API USIOJRequestJSON : public UObject

/** Creates new request with defined verb and content type */
UFUNCTION(BlueprintPure, meta = (DisplayName = "Construct Json Request", HidePin = "WorldContextObject", DefaultToSelf = "WorldContextObject"), Category = "SIOJ|Request")
static USIOJRequestJSON* ConstructRequestExt(UObject* WorldContextObject, ERequestVerb Verb, ERequestContentType ContentType);
static USIOJRequestJSON* ConstructRequestExt(UObject* WorldContextObject, ESIORequestVerb Verb, ESIORequestContentType ContentType);

/** Set verb to the request */
UFUNCTION(BlueprintCallable, Category = "SIOJ|Request")
void SetVerb(ERequestVerb Verb);
void SetVerb(ESIORequestVerb Verb);

/** Set custom verb to the request */
UFUNCTION(BlueprintCallable, Category = "SIOJ|Request")
Expand All @@ -105,7 +105,7 @@ class SIOJSON_API USIOJRequestJSON : public UObject
/** Set content type to the request. If you're using the x-www-form-urlencoded,
* params/constaints should be defined as key=ValueString pairs from Json data */
UFUNCTION(BlueprintCallable, Category = "SIOJ|Request")
void SetContentType(ERequestContentType ContentType);
void SetContentType(ESIORequestContentType ContentType);

/** Set content type of the request for binary post data */
UFUNCTION(BlueprintCallable, Category = "SIOJ|Request")
Expand Down Expand Up @@ -169,7 +169,7 @@ class SIOJSON_API USIOJRequestJSON : public UObject

/** Get status of http request */
UFUNCTION(BlueprintCallable, Category = "SIOJ|Request")
ERequestStatus GetStatus();
ESIORequestStatus GetStatus();

/** Get the response code of the last query */
UFUNCTION(BlueprintCallable, Category = "SIOJ|Response")
Expand Down Expand Up @@ -278,10 +278,10 @@ class SIOJSON_API USIOJRequestJSON : public UObject
USIOJsonObject* ResponseJsonObj;

/** Verb for making request (GET,POST,etc) */
ERequestVerb RequestVerb;
ESIORequestVerb RequestVerb;

/** Content type to be applied for request */
ERequestContentType RequestContentType;
ESIORequestContentType RequestContentType;

/** Mapping of header section to values. Used to generate final header string for request */
TMap<FString, FString> RequestHeaders;
Expand Down
6 changes: 3 additions & 3 deletions Source/SIOJson/Public/SIOJTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

/** Verb (GET, PUT, POST) used by the request */
UENUM(BlueprintType)
enum class ERequestVerb : uint8
enum class ESIORequestVerb : uint8
{
GET,
POST,
Expand All @@ -16,7 +16,7 @@ enum class ERequestVerb : uint8

/** Content type (json, urlencoded, etc.) used by the request */
UENUM(BlueprintType)
enum class ERequestContentType : uint8
enum class ESIORequestContentType : uint8
{
x_www_form_urlencoded_url UMETA(DisplayName = "x-www-form-urlencoded (URL)"),
x_www_form_urlencoded_body UMETA(DisplayName = "x-www-form-urlencoded (Request Body)"),
Expand All @@ -26,7 +26,7 @@ enum class ERequestContentType : uint8

/** Enumerates the current state of an Http request */
UENUM(BlueprintType)
enum class ERequestStatus : uint8
enum class ESIORequestStatus : uint8
{
/** Has not been started via ProcessRequest() */
NotStarted,
Expand Down
2 changes: 1 addition & 1 deletion Source/SocketIOClient/Private/SocketIOClientComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ void USocketIOClientComponent::Connect(const FString& InAddressAndPort)
{
SessionId = FString(TEXT("invalid"));
UE_LOG(SocketIOLog, Log, TEXT("SocketIO Disconnected"));
OnDisconnected.Broadcast((EConnectionCloseReason)reason);
OnDisconnected.Broadcast((ESIOConnectionCloseReason)reason);
}));

PrivateClient.set_socket_open_listener(sio::client::socket_listener([&](std::string const& nsp)
Expand Down

0 comments on commit 3dd5807

Please sign in to comment.