简体   繁体   English

房间内的 OnRoomListUpdate (PUN 2)

[英]OnRoomListUpdate from inside a room (PUN 2)

Short question: how can I get the list of existing rooms while staying in a room?简短的问题:我如何在入住房间时获取现有房间的列表?

Long explanation:长解释:

I am developing a game for a client and I have a problem.我正在为客户开发游戏,但遇到了问题。

In short in the game I can see all the existing rooms from the menu and I can enter one of them (to view the existing rooms I join a lobby and use OnRoomListUpdate ()).简而言之,在游戏中,我可以从菜单中看到所有现有房间,并且可以进入其中一个(要查看现有房间,我加入了一个大厅并使用 OnRoomListUpdate ())。 Entering the room I would like to see the existing rooms again to change room, but I cannot enter a room and stay in the lobby at the same time, and therefore I cannot get the list of available rooms with OnRoomListUpdate ().进入房间我想再次查看现有房间以换房间,但我无法同时进入房间并留在大厅,因此无法通过 OnRoomListUpdate() 获取可用房间列表。

I have been working with Unity and PUN for years, but I can't find an elegant solution to this problem.我多年来一直在使用 Unity 和 PUN,但我找不到一个优雅的解决方案来解决这个问题。

I use PUN 2 and Unity 2021 LTS.我使用 PUN 2 和 Unity 2021 LTS。

Thanks for the support感谢您的支持

Once joining a room within PUN, you get moved from the Master Server (which has the list of all rooms), to a Game Server.一旦加入 PUN 中的房间,您就会从主服务器(包含所有房间的列表)移动到游戏服务器。 There isn't a way to receive room list updates while inside a room because the Game Server simply doesn't have a list of rooms.无法在房间内接收房间列表更新,因为游戏服务器根本没有房间列表。

If you try doing a custom room query, like PhotonNetwork.GetCustomRoomList(TypedLobby.Default, "1=1");如果您尝试进行自定义房间查询,例如PhotonNetwork.GetCustomRoomList(TypedLobby.Default, "1=1"); , it will throw an exception saying it's not allowed on the current server. ,它会抛出一个异常,说它在当前服务器上是不允许的。

Theoretically, it's possible to keep an external list of rooms using Photon Server Webhooks with PathCreate, PathClose, and PathGameProperties, though it might be more trouble than it's worth.从理论上讲,可以使用带有 PathCreate、PathClose 和 PathGameProperties 的Photon Server Webhooks来保留房间的外部列表,尽管这可能比它的价值更麻烦。 (plus, you need your own external server) (另外,您需要自己的外部服务器)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM