mirror of
https://github.com/mordentral/AdvancedSessionsPlugin.git
synced 2025-10-23 16:34:07 +00:00
added invite received delegate
This commit is contained in:
@@ -46,11 +46,12 @@ public:
|
|||||||
FOnSessionInviteReceivedDelegate SessionInviteReceivedDelegate;
|
FOnSessionInviteReceivedDelegate SessionInviteReceivedDelegate;
|
||||||
FDelegateHandle SessionInviteReceivedDelegateHandle;
|
FDelegateHandle SessionInviteReceivedDelegateHandle;
|
||||||
|
|
||||||
void OnSessionInviteReceivedMaster(TSharedPtr<const FUniqueNetId> PersonInvited, TSharedPtr<const FUniqueNetId> PersonInviting, const FOnlineSessionSearchResult& SessionToJoin);
|
//const FUniqueNetId& /*UserId*/, const FUniqueNetId& /*FromId*/, const FString& /*AppId*/, const FOnlineSessionSearchResult& /*InviteResult*/
|
||||||
|
void OnSessionInviteReceivedMaster(const FUniqueNetId & PersonInvited, const FUniqueNetId & PersonInviting, const FString & AppId, const FOnlineSessionSearchResult& SessionToJoin);
|
||||||
|
|
||||||
// After a session invite has been accepted by the local player this event is triggered, call JoinSession on the session result to join it
|
// After a session invite has been accepted by the local player this event is triggered, call JoinSession on the session result to join it
|
||||||
UFUNCTION(BlueprintImplementableEvent, Category = "AdvancedFriends")
|
UFUNCTION(BlueprintImplementableEvent, Category = "AdvancedFriends")
|
||||||
void OnSessionInviteReceived(int32 LocalPlayerNum, FBPUniqueNetId PersonInviting, const FBlueprintSessionResult& SessionToJoin);
|
void OnSessionInviteReceived(int32 LocalPlayerNum, FBPUniqueNetId PersonInviting, const FString& AppId, const FBlueprintSessionResult& SessionToJoin);
|
||||||
|
|
||||||
//*** Session invite accepted by local ***//
|
//*** Session invite accepted by local ***//
|
||||||
FOnSessionUserInviteAcceptedDelegate SessionInviteAcceptedDelegate;
|
FOnSessionUserInviteAcceptedDelegate SessionInviteAcceptedDelegate;
|
||||||
|
@@ -129,7 +129,7 @@ public:
|
|||||||
|
|
||||||
// Get the number of network players
|
// Get the number of network players
|
||||||
UFUNCTION(BlueprintPure, Category = "Online|AdvancedSessions|PlayerInfo|Misc", meta = (bIgnoreSelf = "true", WorldContext = "WorldContextObject", DisplayName = "GetNumNetworkPlayers"))
|
UFUNCTION(BlueprintPure, Category = "Online|AdvancedSessions|PlayerInfo|Misc", meta = (bIgnoreSelf = "true", WorldContext = "WorldContextObject", DisplayName = "GetNumNetworkPlayers"))
|
||||||
static void GetNumberOfNetworkPlayers(int32 &NumNetPlayers);
|
static void GetNumberOfNetworkPlayers(UObject* WorldContextObject, int32 &NumNetPlayers);
|
||||||
|
|
||||||
// Get the network player index of the given controller
|
// Get the network player index of the given controller
|
||||||
UFUNCTION(BlueprintPure, Category = "Online|AdvancedSessions|PlayerInfo|Misc")
|
UFUNCTION(BlueprintPure, Category = "Online|AdvancedSessions|PlayerInfo|Misc")
|
||||||
|
@@ -29,7 +29,7 @@ void UAdvancedFriendsGameInstance::Shutdown()
|
|||||||
{
|
{
|
||||||
// Clear all of the delegate handles here
|
// Clear all of the delegate handles here
|
||||||
SessionInterface->ClearOnSessionUserInviteAcceptedDelegate_Handle(SessionInviteAcceptedDelegateHandle);
|
SessionInterface->ClearOnSessionUserInviteAcceptedDelegate_Handle(SessionInviteAcceptedDelegateHandle);
|
||||||
|
SessionInterface->ClearOnSessionInviteReceivedDelegate_Handle(SessionInviteReceivedDelegateHandle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -63,6 +63,7 @@ void UAdvancedFriendsGameInstance::Init()
|
|||||||
// Multiple logins either (IE: Steam)
|
// Multiple logins either (IE: Steam)
|
||||||
SessionInviteAcceptedDelegateHandle = SessionInterface->AddOnSessionUserInviteAcceptedDelegate_Handle(SessionInviteAcceptedDelegate);
|
SessionInviteAcceptedDelegateHandle = SessionInterface->AddOnSessionUserInviteAcceptedDelegate_Handle(SessionInviteAcceptedDelegate);
|
||||||
|
|
||||||
|
SessionInviteReceivedDelegateHandle = SessionInterface->AddOnSessionInviteReceivedDelegate_Handle(SessionInviteReceivedDelegate);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -157,7 +158,7 @@ void UAdvancedFriendsGameInstance::OnPlayerTalkingStateChangedMaster(TSharedRef<
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void UAdvancedFriendsGameInstance::OnSessionInviteReceivedMaster(TSharedPtr<const FUniqueNetId> PersonInvited, TSharedPtr<const FUniqueNetId> PersonInviting, const FOnlineSessionSearchResult& SessionToJoin)
|
void UAdvancedFriendsGameInstance::OnSessionInviteReceivedMaster(const FUniqueNetId & PersonInvited, const FUniqueNetId & PersonInviting, const FString& AppId, const FOnlineSessionSearchResult& SessionToJoin)
|
||||||
{
|
{
|
||||||
if (SessionToJoin.IsValid())
|
if (SessionToJoin.IsValid())
|
||||||
{
|
{
|
||||||
@@ -165,10 +166,10 @@ void UAdvancedFriendsGameInstance::OnSessionInviteReceivedMaster(TSharedPtr<cons
|
|||||||
BluePrintResult.OnlineResult = SessionToJoin;
|
BluePrintResult.OnlineResult = SessionToJoin;
|
||||||
|
|
||||||
FBPUniqueNetId PInvited;
|
FBPUniqueNetId PInvited;
|
||||||
PInvited.SetUniqueNetId(PersonInvited);
|
PInvited.SetUniqueNetId(&PersonInvited);
|
||||||
|
|
||||||
FBPUniqueNetId PInviting;
|
FBPUniqueNetId PInviting;
|
||||||
PInviting.SetUniqueNetId(PersonInviting);
|
PInviting.SetUniqueNetId(&PersonInviting);
|
||||||
|
|
||||||
|
|
||||||
TArray<APlayerController*> PlayerList;
|
TArray<APlayerController*> PlayerList;
|
||||||
@@ -177,17 +178,17 @@ void UAdvancedFriendsGameInstance::OnSessionInviteReceivedMaster(TSharedPtr<cons
|
|||||||
APlayerController* Player = NULL;
|
APlayerController* Player = NULL;
|
||||||
|
|
||||||
int32 LocalPlayer = 0;
|
int32 LocalPlayer = 0;
|
||||||
for (int i = 0; i < PlayerList->Num(); i++)
|
for (int i = 0; i < PlayerList.Num(); i++)
|
||||||
{
|
{
|
||||||
if (PlayerList[i]->PlayerState->UniqueId == PersonInvited)
|
if (*PlayerList[i]->PlayerState->UniqueId.GetUniqueNetId() == PersonInvited)
|
||||||
{
|
{
|
||||||
PlayerNum = i;
|
LocalPlayer = i;
|
||||||
Player = PlayerList[i];
|
Player = PlayerList[i];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
OnSessionInviteReceived(LocalPlayer, PInviting, BluePrintResult);
|
OnSessionInviteReceived(LocalPlayer, PInviting, AppId, BluePrintResult);
|
||||||
|
|
||||||
IAdvancedFriendsInterface* TheInterface = NULL;
|
IAdvancedFriendsInterface* TheInterface = NULL;
|
||||||
|
|
||||||
|
@@ -374,7 +374,7 @@ void UAdvancedSessionsLibrary::GetPlayerName(APlayerController *PlayerController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void UAdvancedSessionsLibrary::GetNumberOfNetworkPlayers(int32 &NumNetPlayers)
|
void UAdvancedSessionsLibrary::GetNumberOfNetworkPlayers(UObject* WorldContextObject, int32 &NumNetPlayers)
|
||||||
{
|
{
|
||||||
//Get an actor to GetWorld() from
|
//Get an actor to GetWorld() from
|
||||||
/*TObjectIterator<AActor> Itr;
|
/*TObjectIterator<AActor> Itr;
|
||||||
@@ -386,7 +386,7 @@ void UAdvancedSessionsLibrary::GetNumberOfNetworkPlayers(int32 &NumNetPlayers)
|
|||||||
//~~~~~~~~~~~~
|
//~~~~~~~~~~~~
|
||||||
|
|
||||||
//Get World
|
//Get World
|
||||||
UWorld* TheWorld = GEngine->GetWorldFromContextObject(WorldContextObject)
|
UWorld* TheWorld = GEngine->GetWorldFromContextObject(WorldContextObject);
|
||||||
|
|
||||||
if (!TheWorld)
|
if (!TheWorld)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user