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,35 +6,35 @@ class Mumble extends Core {
|
|||
this.options.socketTimeout = 5000;
|
||||
}
|
||||
|
||||
run(state) {
|
||||
this.tcpSend('json', (buffer) => {
|
||||
if(buffer.length < 10) return;
|
||||
const str = buffer.toString();
|
||||
let json;
|
||||
try {
|
||||
json = JSON.parse(str);
|
||||
} catch(e) {
|
||||
// probably not all here yet
|
||||
return;
|
||||
}
|
||||
|
||||
state.raw = json;
|
||||
state.name = json.name;
|
||||
|
||||
let channelStack = [state.raw.root];
|
||||
while(channelStack.length) {
|
||||
const channel = channelStack.shift();
|
||||
channel.description = this.cleanComment(channel.description);
|
||||
channelStack = channelStack.concat(channel.channels);
|
||||
for(const user of channel.users) {
|
||||
user.comment = this.cleanComment(user.comment);
|
||||
state.players.push(user);
|
||||
async run(state) {
|
||||
const json = await this.withTcp(async socket => {
|
||||
return await this.tcpSend(socket, 'json', (buffer) => {
|
||||
if (buffer.length < 10) return;
|
||||
const str = buffer.toString();
|
||||
let json;
|
||||
try {
|
||||
json = JSON.parse(str);
|
||||
} catch (e) {
|
||||
// probably not all here yet
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
this.finish(state);
|
||||
return true;
|
||||
return json;
|
||||
});
|
||||
});
|
||||
|
||||
state.raw = json;
|
||||
state.name = json.name;
|
||||
|
||||
let channelStack = [state.raw.root];
|
||||
while(channelStack.length) {
|
||||
const channel = channelStack.shift();
|
||||
channel.description = this.cleanComment(channel.description);
|
||||
channelStack = channelStack.concat(channel.channels);
|
||||
for(const user of channel.users) {
|
||||
user.comment = this.cleanComment(user.comment);
|
||||
state.players.push(user);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cleanComment(str) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue