-
Notifications
You must be signed in to change notification settings - Fork 450
feat: OnAllClientsReady #755
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
These events forward the events from any individual SceneSwitchProgress to a single endpoint.
… the server recieves acknowledgement that all clients have successfully loaded the scene (or timed out)
…tsReady callback - this way we can know specifically, which users failed to load the scene before the transition timed out
…he client, switched it over so that the array of timedout client IDs is properly computed on the server.
…nity.multiplayer.mlapi into feature/onclientready-mtt588 # Conflicts: # com.unity.multiplayer.mlapi/Tests/Runtime/NetworkManagerHelper.cs # testproject/ProjectSettings/EditorBuildSettings.asset
var timedOutClientIds = m_NetworkManager.ConnectedClients.Keys.Except(doneClientIds).ToArray(); | ||
|
||
writer.WriteULongArray(doneClientIds, doneClientIds.Length); | ||
writer.WriteULongArray(timedOutClientIds, timedOutClientIds.Length); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! Both active and timed out clients!
Very useful!
/// <returns>true if it was instantiated or is already instantiate otherwise false means it failed to instantiate</returns> | ||
public static bool StartNetworkManager(out NetworkManager networkManager, NetworkManagerOperatingMode managerMode = NetworkManagerOperatingMode.Host) | ||
public static bool StartNetworkManager(out NetworkManager networkManager, NetworkManagerOperatingMode managerMode = NetworkManagerOperatingMode.Host, NetworkConfig networkConfig = null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding NetworkConfig will come in handy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks real good Philipp!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are some issues with the NetworkManagerHelper and the way you are loading scenes.
Grab me when you have a second to discuss.
trying to make Yamato like me
…t locates the full path to a scene for the Setup stage.
…ts/.. and in SceneManager list from the package dll on Yamato, the automated tests were removed and a manual test was created instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We will fix the NetworkSceneManager issue in the very near future.
The rest looks good to go!
com.unity.multiplayer.mlapi/Runtime/SceneManagement/NetworkSceneManager.cs
Outdated
Show resolved
Hide resolved
…andable at a glance
…nity.multiplayer.mlapi into feature/onclientready-mtt588 # Conflicts: # testproject/Assets/ManualTests/ManualTestsMenu.unity
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The adjusted event names look good.
Very clear what each one does at this point
Summary:
Users need a simplified way to determine when all clients have finished transitioning to a newly loaded scene so net-code related logic (i.e. sending messages, detecting network variable states, etc) can safely begin.
Technical Notes:
On the server-side currently not much needed to be done - we already have
SceneSwitchProgress
object created for any scene switches. The only hindrance here is that the user has to cacheSceneSwitchProgress
in order to be able to listen to it's events. We can capture these events inNetworkSceneManager
and provide a unified set of events one can listen to without needing to re-subscribe to the events any time a new scene is being loaded.Two events are added to the
NetworkSceneManager
that forward theSceneSwitchProgress
events (those happen only on the server):On the client-side this can be accomplished by implementing a new internal MLAPI message event (NetworkConstants.ALL_CLIENTS_SWITCH_SCENE_COMPLETED).
This message is sent (along with lists of all connected and timed-out clients) to the clients as soon as the server knows that all clients have concluded their scene transitions. The message is then handled in
InternalMessageHandler.HandleAllClientsSwitchSceneCompleted
, which triggersNetworkSceneManager.OnAllClientsReady
event on all the clients.Acceptance Criteria:
Nothing should break - the change is purely additive.
It should be simpler to implement scene switching logic on the client and on the server and it should eliminate the need for custom messaging that the users will have to implement to achieve the same functionality.
Acceptance Tests: