mirror of
https://github.com/tribufu/node-gamedig
synced 2026-05-18 09:35:50 +00:00
More async conversion
This commit is contained in:
parent
484e99b29c
commit
efe12a00aa
25 changed files with 774 additions and 858 deletions
|
|
@ -6,30 +6,28 @@ class M2mp extends Core {
|
|||
this.encoding = 'latin1';
|
||||
}
|
||||
|
||||
run(state) {
|
||||
this.udpSend('M2MP',(buffer) => {
|
||||
async run(state) {
|
||||
const body = await this.udpSend('M2MP',(buffer) => {
|
||||
const reader = this.reader(buffer);
|
||||
|
||||
const header = reader.string({length:4});
|
||||
if(header !== 'M2MP') return;
|
||||
|
||||
state.name = this.readString(reader);
|
||||
state.raw.numplayers = this.readString(reader);
|
||||
state.maxplayers = this.readString(reader);
|
||||
state.raw.gamemode = this.readString(reader);
|
||||
state.password = !!reader.uint(1);
|
||||
|
||||
while(!reader.done()) {
|
||||
const name = this.readString(reader);
|
||||
if(!name) break;
|
||||
state.players.push({
|
||||
name:name
|
||||
});
|
||||
}
|
||||
|
||||
this.finish(state);
|
||||
return true;
|
||||
const header = reader.string({length: 4});
|
||||
if (header !== 'M2MP') return;
|
||||
return reader.rest();
|
||||
});
|
||||
|
||||
const reader = this.reader(body);
|
||||
state.name = this.readString(reader);
|
||||
state.raw.numplayers = this.readString(reader);
|
||||
state.maxplayers = this.readString(reader);
|
||||
state.raw.gamemode = this.readString(reader);
|
||||
state.password = !!reader.uint(1);
|
||||
|
||||
while(!reader.done()) {
|
||||
const name = this.readString(reader);
|
||||
if(!name) break;
|
||||
state.players.push({
|
||||
name:name
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
readString(reader) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue