seishun / node-steam

Interface directly with Steam servers from Node.js
MIT License
1k stars 180 forks source link

node-steam hangs up #438

Closed SzymonLisowiec closed 6 years ago

SzymonLisowiec commented 6 years ago

My script and your node_modules/steam/example.js not working. Library don't receiving any messages from Steam.

hackteck commented 6 years ago

Server list is outdated. Here is my solution to fix it (ty scholtzm)

async function loadServerList() {
    let response = await $.httpGetJson("https://api.steampowered.com/ISteamDirectory/GetCMList/v1/?format=json&cellid=0");
    Steam.servers = [];
    for (const server of response.response.serverlist) {
        let _server = server.split(":");
        Steam.servers.push({ "host": _server[0], "port": _server[1] });
    }
}
xc4t commented 6 years ago

where exactly should I put this code? I have no idea

xc4t commented 6 years ago

can someone please help :p

SzymonLisowiec commented 6 years ago
const Steam = require('steam');
const Request = require('request-promise-native');

(async _ => {
    await loadServerList();
    // Your script 
})();

async function loadServerList() {
    let response = await Request('https://api.steampowered.com/ISteamDirectory/GetCMList/v1/?format=json&cellid=0');
    response = JSON.parse(response);
    Steam.servers = [];
    for (const server of response.response.serverlist) {
        let _server = server.split(":");
        Steam.servers.push({ "host": _server[0], "port": _server[1] });
    }
}
xc4t commented 6 years ago

thanks!