Does Photon PUN OfflineMode accurately simulate live matchmaking callbacks?
0 reputation · 25 May 2023, 05:22 UTC
0 reputation · 25 May 2023, 05:22 UTC
Goal: determine whether enabling PhotonNetwork.OfflineMode in PUN reproduces the exact callback sequence and state changes that occur during a real connection to the Photon Cloud, allowing unit tests to run without credentials or network traffic.
Constraints: the test must avoid any production AppId, must not generate external traffic, and must remain deterministic across runs; uncertainty remains about how OfflineMode handles region selection, room‑creation callbacks, and event ordering compared to a live session.
Does OfflineMode trigger the same OnCreatedRoom and OnJoinedRoom callbacks as a live connection? Does it respect the same region‑selection logic? Are there any differences in event ordering or latency simulation?
Photon Unity Networking’s PhotonNetwork.OfflineMode does not fully reproduce the callback sequence that you would see when connected to a real Photon Cloud instance. It simulates only the basic connection and room‑joining callbacks that are driven locally by the client, but it skips the server‑side matchmaking logic that generates OnMatchList, OnJoinRandomFailed, and OnJoinRandomSuccess events.
OfflineMode is enabled, OnConnectedToMaster and OnJoinedRoom are invoked just as they would be in a live session.OfflineMode is active because the client never contacts a Photon server.The OfflineMode flag instructs the Photon runtime to skip all network I/O. Room creation and join operations are handled internally by the client’s local lobby manager, which immediately triggers the relevant callbacks. Because matchmaking is a server‑side operation that requires querying a matchmaking queue or a lobby service, the client cannot generate those callbacks without an active connection.
PhotonNetwork.OfflineMode = true before calling PhotonNetwork.ConnectUsingSettings().
OnConnectedToMaster and OnJoinedRoom as usual.
PhotonNetwork.CreateRoom("TestRoom") or PhotonNetwork.JoinRoom("TestRoom") – the callbacks will fire immediately.
OfflineMode = false and a valid AppId. Observe that OnMatchList, OnJoinRandomFailed, and OnJoinRandomSuccess are now invoked.
To refine this recommendation for your project, could you confirm which Photon PUN version you are targeting? Different minor releases may contain subtle changes to the OfflineMode implementation.
OnMatchList will fire in OfflineMode – it never will.
Use comments to ask for clarification. Post a solution as an answer.
34,775 reputation · 25 May 2023, 13:51 UTC
When PhotonNetwork.OfflineMode is enabled, the client still runs through the normal connection flow and invokes OnConnectedToMaster, OnJoinedLobby and OnJoinedRoom on the main Unity thread immediately after PhotonNetwork.ConnectUsingSettings(). Importantly, the PhotonNetwork.GameVersion value is still read and used for internal caching, so any logic that branches on the version string behaves identically to an online build. However, region selection, custom authentication and server‑side room limits are completely bypassed, and no latency or packet‑loss simulation occurs.