greenheartgames / greenworks

a node.js plugin to integrate nw.js/electron games with steamworks
MIT License
1.49k stars 153 forks source link

Matchmaking do not support RequestLobbyList in steamworksSDK? #325

Open fzygit1 opened 8 months ago

fzygit1 commented 8 months ago

i want search lobbies list,but I found no information about RequestLobbyList in the Matchmaking.md,

https://partner.steamgames.com/doc/api/ISteamMatchmaking#RequestLobbyList

hokein commented 8 months ago

This API is not exposed in Greenworks yet.

fzygit1 commented 8 months ago

This API is not exposed in Greenworks yet.

Thank you very much for your answer ! So, if I want to invite friends and play P2P online games, is it not possible with greenworks?

Hocti commented 1 month ago
const getLobbyCount = (maxFetch=1024) => {
    if(!greenworks.getLobbyByIndex(0).isLobby())return 0;
    let maxFail=1;
    while(greenworks.getLobbyByIndex(maxFail).isLobby()){
        maxFail*=2;
        if(maxFail>maxFetch)break;
    }
    if(maxFail===1){
        return 1;
    }
    let minOK=maxFail-maxFail/2;
    testNum=maxFail/4;
    do{
        if(greenworks.getLobbyByIndex(maxFail-testNum).isLobby()){
            minOK=maxFail-testNum;
        }else{
            maxFail=maxFail-testNum;
        }
        testNum/=2;
    }while(testNum>=1);
    return minOK+1;
}

I wrote this to get the current lobby count. (For now, I hope Greenworks updates too.) If there are 999 lobbies, it just needs 21 calls to getLobbyByIndex to find the total number.

After that, use greenworks.getLobbyByIndex(123).getRawSteamID() in a loop to get all the lobby IDs (you can paginate it).