Replies: 3 comments
-
so, it should return any created room, using some conditions, and this conditions are the room object conditions, name, locked, private etc class game_room extends Room{
}
gameServer.define('game', game_room'); ///defined but not created yet
let query = await matchMaker.query({}); ///will return nothing because there's no room created yet
await matchMaker.createRoom('game');
query = await matchMaker.query({}); ///will return all your created rooms, so the game rooms
query = await matchMaker.query({name: 'game'}); /// will return only the game_rooms you can also set some metadata or increase the conditions options by using the redis presence, also, the condition can't be any room variable, just the room structure like name, locked, private, clients, max clients metadata and etc |
Beta Was this translation helpful? Give feedback.
-
Hey there. I appreciate your reply. I'm not sure what happened but when I woke up this morning and tried it again, everything seemed to be working. I'm going to blame it on an ill-advised late night coding session. One last question if you don't mind: Can you query metadata or custom properties using this method? For example, if you had something like room.setMetadata({organization: 2}) or maybe just room.organization, could you do something like matchMaker.query({organization: 2}) and expect a result? If not, would the best way to achieve the above be to query all rooms (a potentially long list in some cases I'd imagine) and just filter it yourself? Thanks! |
Beta Was this translation helpful? Give feedback.
-
well, if i'm not wrong, you need the presence with redis to use the metadata for query, and even if you query all the rooms without it, you will not be able to check that properties, so you need to set metadata, i don't have tested yet if you can query by the metadata, i'm going to make some tests, but what i'm doing is. //room
this.setMetadata("map", "lobby");
//query
let lobby_rooms = (await matchMaker.query({})).filter((_r) => _r.metadata.map == "lobby"); but i will test if i can put metadata properties right into the query |
Beta Was this translation helpful? Give feedback.
-
I'm trying to understand how to use matchMaker.query. Unfortunately, the documentation is pretty scarce. The single parameter is named "conditions" but it isn't clear what what refers to. In my TypeScript project, it points to a data type named RoomListingData but even when using those properties it doesn't return any results.
I found another post here (a couple of years old) that suggested calling matchMaker.query({locked: false, private: false}) would return the same result as client.getAvailableRooms but that doesn't appear to be true. The latter correct returns all of the rooms but the former returns nothing.
Any ideas?
Beta Was this translation helpful? Give feedback.
All reactions