PlayFab / PlayFabMultiplayerUnreal

PlayFab Online Subsystem Plugin for Unreal Engine
https://learn.microsoft.com/en-us/gaming/playfab/features/multiplayer/networking/party-unreal-engine-oss-overview
39 stars 35 forks source link

Critically missing examples/workflow docs (both online+inline) #31

Closed dylanh724 closed 1 year ago

dylanh724 commented 1 year ago

There's 0 direction I could find except how to install the plugin. Not even the inline docs have a single comment except the redundant name of the function.

image

Where are the other OSS docs?

  1. Where/how do I init the SDK, if any?
  2. Does this SDK use singletons, mostly, like the client sdk? Some sample API interactions.
  3. Why would I call OnlineIdentiyInterfacePlayFab::TriggerOnLoginCompleteDelegates after already logged in? What does this actually trigger?
  4. Workflow? Best practices?
  5. Matchmaking events?

I'm struggling to find anything past how to install the plugin.

yuehanlin commented 1 year ago

Thanks for your questions, and here are the answers to your question.

1&2. After adding below code (details please view PlayFab Online Subsystem (OSS) Quickstart - PlayFab | Microsoft Learn)


[OnlineSubsystem]
DefaultPlatformService=PlayFab

UE OnlineSubsystemModule will use create online subsystem instance for PlayFab, therefore will start create ⁠PlayFabSingleton,%7D,-else). At this point, SDK is initialized in⁠ [FOnlineSubsystemPlayFab::Init()](https://github.com/PlayFab/PlayFabMultiplayerUnreal/blob/main/Source/Private/OnlineSubsystemPlayFab.cpp#:~:text=bool%20FOnlineSubsystemPlayFab%3A%3AInit()), where it'll initialize both Party and Multiplayer SDK with PlayFab TitleID (this titleID is defined inside your platform.ini file which is shown in PlayFab Online Subsystem (OSS) Quickstart - PlayFab | Microsoft Learn). During initialization, we'll ⁠[CreatePlayFabSocketSubsystem()](https://github.com/PlayFab/PlayFabMultiplayerUnreal/blob/main/Source/Private/OnlineSubsystemPlayFab.cpp#:~:text=CreatePlayFabSocketSubsystem()) as main online subsystem. 

In this repo, we manage Party SDK use ⁠[Singleton](https://github.com/PlayFab/PlayFabMultiplayerUnreal/blob/main/Source/Private/OnlineSubsystemPlayFab.cpp#:~:text=void%20FOnlineSubsystemPlayFab%3A%3ADoWork,PartyManager%3A%3AGetSingleton()%3B) structure, which handles the PartyStateChangeType get from ⁠Party library. For Multiplayer, view 4&5.

3.This TriggerOnLoginCompleteDelegates was used for handling when login was unsuccessful for a user. Now, we are managing the login users using ⁠UsersToAuth .

4&5.Workflow of Multiplayer SDK: FOnlineSubsystemPlayFab::Init() initialize the MatchmakingInterface and PlayFabLobbyInterface . These 2 interfaces calling ⁠[Dowork()](https://github.com/PlayFab/PlayFabMultiplayerUnreal/blob/main/Source/Private/OnlineSessionInterfacePlayFab.cpp#:~:text=OSSPlayFab%2D%3EGetPlayFabLobbyInterface()%2D%3EDoWork,OSSPlayFab%2D%3EGetMatchmakingInterface()%2D%3EDoWork()%3B) which will handle the states changes from PFMultiplayerStartProcessingMatchmakingStateChanges and PFMultiplayerStartProcessingLobbyStateChanges (view Platforms//Include/PFMatchmaking.h and PFLobby.h to see these 2 functions).

dylanh724 commented 1 year ago

Thanks for your questions, and here are the answers to your question.

1&2. After adding below code (details please view PlayFab Online Subsystem (OSS) Quickstart - PlayFab | Microsoft Learn)


[OnlineSubsystem]
DefaultPlatformService=PlayFab

UE OnlineSubsystemModule will use create online subsystem instance for PlayFab, therefore will start create ⁠PlayFabSingleton,%7D,-else). At this point, SDK is initialized in⁠ [FOnlineSubsystemPlayFab::Init()](https://github.com/PlayFab/PlayFabMultiplayerUnreal/blob/main/Source/Private/OnlineSubsystemPlayFab.cpp#:~:text=bool%20FOnlineSubsystemPlayFab%3A%3AInit()), where it'll initialize both Party and Multiplayer SDK with PlayFab TitleID (this titleID is defined inside your platform.ini file which is shown in PlayFab Online Subsystem (OSS) Quickstart - PlayFab | Microsoft Learn). During initialization, we'll ⁠[CreatePlayFabSocketSubsystem()](https://github.com/PlayFab/PlayFabMultiplayerUnreal/blob/main/Source/Private/OnlineSubsystemPlayFab.cpp#:~:text=CreatePlayFabSocketSubsystem()) as main online subsystem. 

In this repo, we manage Party SDK use ⁠[Singleton](https://github.com/PlayFab/PlayFabMultiplayerUnreal/blob/main/Source/Private/OnlineSubsystemPlayFab.cpp#:~:text=void%20FOnlineSubsystemPlayFab%3A%3ADoWork,PartyManager%3A%3AGetSingleton()%3B) structure, which handles the PartyStateChangeType get from ⁠Party library. For Multiplayer, view 4&5.

3.This TriggerOnLoginCompleteDelegates was used for handling when login was unsuccessful for a user. Now, we are managing the login users using ⁠UsersToAuth .

4&5.Workflow of Multiplayer SDK: FOnlineSubsystemPlayFab::Init() initialize the MatchmakingInterface and PlayFabLobbyInterface . These 2 interfaces calling ⁠[Dowork()](https://github.com/PlayFab/PlayFabMultiplayerUnreal/blob/main/Source/Private/OnlineSessionInterfacePlayFab.cpp#:~:text=OSSPlayFab%2D%3EGetPlayFabLobbyInterface()%2D%3EDoWork,OSSPlayFab%2D%3EGetMatchmakingInterface()%2D%3EDoWork()%3B) which will handle the states changes from PFMultiplayerStartProcessingMatchmakingStateChanges and PFMultiplayerStartProcessingLobbyStateChanges (view Platforms//Include/PFMatchmaking.h and PFLobby.h to see these 2 functions).

This is great!

Any chance you can toss this to the Unreal OSS quickstart doc? With even more details, if possible -- it's really only you that knows this. If we pop in the PF discord or forum, no PF staff seems to know anything about this SDK. Only you folks can help others.

The current quickstart only shows how to set it up and is missing best practices, workflow, entry points, high level overviews, etc.

One thing that is desperately missing that I forgot to ask is OSS:PF vocab maps. For example, your OSS ResourceId isn't found in the PF API documentation. What this actually is called in PF is MatchId. No one could ever possibly know this unless you meta search beyond the official docs, buried somewhere in Google.

yuehanlin commented 1 year ago

Thanks for your feedback. We've filed a bug to update the document to include your suggestions.

dylanh724 commented 1 year ago

FOnlineSubsystemPlayFab::Init()

Hey just a quick follow-up question:

image

What is the default for ReplicationDriverClassName? Where would I generally find out if I use a "custom replication driver class"?

yuehanlin commented 1 year ago

It's likely to be found at MyGame/Config/DefaultEngine.ini file. Find [/Script/OnlineSubsystemUtils.IpNetDriver] section or search ReplicationDriverClassName, and the value should looks like: ReplicationDriverClassName="/Script/MyGame.MyReplicationGraph"

dylanh724 commented 1 year ago

It's likely to be found at MyGame/Config/DefaultEngine.ini file. Find [/Script/OnlineSubsystemUtils.IpNetDriver] section or search ReplicationDriverClassName, and the value should looks like: ReplicationDriverClassName="/Script/MyGame.MyReplicationGraph"

Perfect, thanks!!

yuehanlin commented 1 year ago

Workflow of OSS was added into the new release document https://learn.microsoft.com/en-us/gaming/playfab/features/multiplayer/networking/party-unreal-engine-oss-quickstart#workflow-of-pf-oss, so I'll close this issue.