Update Game Instance for Joining via Lobby Code
This commit is contained in:
		
							parent
							
								
									8ac4588aed
								
							
						
					
					
						commit
						a85c60cbf1
					
				@ -1,3 +1,3 @@
 | 
			
		||||
version https://git-lfs.github.com/spec/v1
 | 
			
		||||
oid sha256:626aeae1e79975c59fdf35d793d2a62fbbb0bb0ed9f61829d0523238dc831158
 | 
			
		||||
size 1198885
 | 
			
		||||
oid sha256:3272aecd605e97dead183751dc40c88bc6f59cd5511f9850f949e1f49c8c1f93
 | 
			
		||||
size 1293433
 | 
			
		||||
 | 
			
		||||
@ -103,6 +103,17 @@ void UCMGameInstance::GetServerLobbyList()
 | 
			
		||||
	Request->ProcessRequest();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void UCMGameInstance::GetLobbyByID(const FString LobbyID)
 | 
			
		||||
{
 | 
			
		||||
	const auto Request = FHttpModule::Get().CreateRequest();
 | 
			
		||||
	Request->SetURL(LobbyAPI + "/lobbies/id/" + LobbyID);
 | 
			
		||||
	Request->SetVerb("GET");
 | 
			
		||||
	Request->SetHeader("Authorization", "Bearer " + JwtToken);
 | 
			
		||||
	Request->SetHeader("Accept", "application/json");
 | 
			
		||||
	Request->OnProcessRequestComplete().BindUObject(this, &UCMGameInstance::OnRequestToGetLobbyByIDComplete);
 | 
			
		||||
	Request->ProcessRequest();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void UCMGameInstance::ReadyUp()
 | 
			
		||||
{
 | 
			
		||||
	const TSharedPtr<FJsonObject> ReadyUp = MakeShareable(new FJsonObject);
 | 
			
		||||
@ -416,3 +427,25 @@ void UCMGameInstance::OnRequestToGetServerLobbyListComplete(FHttpRequestPtr Requ
 | 
			
		||||
		OnServerLobbyListComplete.Broadcast(false);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void UCMGameInstance::OnRequestToGetLobbyByIDComplete(FHttpRequestPtr Request, FHttpResponsePtr Response, bool bWasSuccessful)
 | 
			
		||||
{
 | 
			
		||||
	if (bWasSuccessful)
 | 
			
		||||
	{
 | 
			
		||||
		const auto JsonReader = TJsonReaderFactory<>::Create(Response->GetContentAsString());
 | 
			
		||||
		if (TSharedPtr<FJsonObject> JsonObject; FJsonSerializer::Deserialize(JsonReader, JsonObject))
 | 
			
		||||
		{
 | 
			
		||||
			const auto JsonLobbyID = JsonObject->GetStringField("id");
 | 
			
		||||
			const auto JsonMaxPlayers = JsonObject->GetIntegerField("maxPlayers");
 | 
			
		||||
			OnGetLobbyByID.Broadcast(true, JsonLobbyID, JsonMaxPlayers);
 | 
			
		||||
		}
 | 
			
		||||
		else
 | 
			
		||||
		{
 | 
			
		||||
			OnGetLobbyByID.Broadcast(false, "AAAAA", 0);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	else
 | 
			
		||||
	{
 | 
			
		||||
		OnGetLobbyByID.Broadcast(false, "AAAAA", 0);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -32,6 +32,8 @@ public:
 | 
			
		||||
 | 
			
		||||
	DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnServerLobbyListComplete, const bool, bWasSuccessful);
 | 
			
		||||
 | 
			
		||||
	DECLARE_DYNAMIC_MULTICAST_DELEGATE_ThreeParams(FOnGetLobbyByID, const bool, bWasSuccessful, const FString, LobbyID, const int, MaxPlayers);
 | 
			
		||||
 | 
			
		||||
	DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnPlayerJoin, const FString, PlayerName);
 | 
			
		||||
 | 
			
		||||
	DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnPlayerLeave, const FString, PlayerName);
 | 
			
		||||
@ -59,6 +61,8 @@ public:
 | 
			
		||||
	UPROPERTY(BlueprintAssignable, Category = "Lobby")
 | 
			
		||||
	FOnServerLobbyListComplete OnServerLobbyListComplete;
 | 
			
		||||
	UPROPERTY(BlueprintAssignable, Category = "Lobby")
 | 
			
		||||
	FOnGetLobbyByID OnGetLobbyByID;
 | 
			
		||||
	UPROPERTY(BlueprintAssignable, Category = "Lobby")
 | 
			
		||||
	FOnPlayerJoin OnPlayerJoin;
 | 
			
		||||
	UPROPERTY(BlueprintAssignable, Category = "Lobby")
 | 
			
		||||
	FOnPlayerLeave OnPlayerLeave;
 | 
			
		||||
@ -102,6 +106,8 @@ public:
 | 
			
		||||
	UFUNCTION(BlueprintCallable, Category = "Lobby")
 | 
			
		||||
	void GetServerLobbyList();
 | 
			
		||||
	UFUNCTION(BlueprintCallable, Category = "Lobby")
 | 
			
		||||
	void GetLobbyByID(const FString LobbyID);
 | 
			
		||||
	UFUNCTION(BlueprintCallable, Category = "Lobby")
 | 
			
		||||
	void ReadyUp();
 | 
			
		||||
	UFUNCTION(BlueprintCallable, Category = "Lobby")
 | 
			
		||||
	void UnReady();
 | 
			
		||||
@ -123,4 +129,5 @@ private:
 | 
			
		||||
	void OnRequestToLeaveLobbyComplete(FHttpRequestPtr Request, FHttpResponsePtr Response, bool bWasSuccessful);
 | 
			
		||||
	void OnRequestToGetLobbyPlayersComplete(FHttpRequestPtr Request, FHttpResponsePtr Response, bool bWasSuccessful);
 | 
			
		||||
	void OnRequestToGetServerLobbyListComplete(FHttpRequestPtr Request, FHttpResponsePtr Response, bool bWasSuccessful);
 | 
			
		||||
	void OnRequestToGetLobbyByIDComplete(FHttpRequestPtr Request, FHttpResponsePtr Response, bool bWasSuccessful);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user