Archer

Advanced - Mahjong Event Login

Basic Review

In the previous section, we introduced the basic callback function for Mahjong event login. However, in real game scenarios, when this is invoked, it is not certain whether the player has already entered the game lobby. Further checks are needed to determine whether the player has entered the game and if the game has started.

How to Determine

Warning

Update (Majsoul Unity migration): After Majsoul's web client moved to Unity + WASM, the UI-state "manager" packages such as lobbymgr have been removed — they relied on LayaBox engine JS globals that no longer exist under Unity. As a result, you can no longer use lobbymgr.Inst().Enable() (or similar) to tell whether you are in the lobby.

Determine the game phase from the in-game event stream (protobuf messages) instead: in the login / enter-room / game-start event callbacks, infer the current state from the protocol messages you receive, rather than querying the front-end UI. The exact logic depends on the events you actually receive.