node-gamedig/protocols/mumbleping.js

27 lines
745 B
JavaScript
Raw Normal View History

const Core = require('./core');
class MumblePing extends Core {
2017-08-09 12:32:09 +02:00
constructor() {
super();
this.byteorder = 'be';
}
2019-01-10 13:03:07 +01:00
async run(state) {
const data = await this.udpSend('\x00\x00\x00\x00\x01\x02\x03\x04\x05\x06\x07\x08', (buffer) => {
if (buffer.length >= 24) return buffer;
2017-08-09 12:32:09 +02:00
});
2019-01-10 13:03:07 +01:00
const reader = this.reader(data);
reader.skip(1);
state.raw.versionMajor = reader.uint(1);
state.raw.versionMinor = reader.uint(1);
state.raw.versionPatch = reader.uint(1);
reader.skip(8);
2019-02-04 08:11:28 +01:00
state.players = reader.uint(4);
2019-01-10 13:03:07 +01:00
state.maxplayers = reader.uint(4);
state.raw.allowedbandwidth = reader.uint(4);
2017-08-09 12:32:09 +02:00
}
}
module.exports = MumblePing;