mirror of
https://github.com/plantroon/mx-puppet-xmpp.git
synced 2024-12-23 07:01:47 +00:00
hopefully fix up restarting stuffs better
This commit is contained in:
parent
c777235aad
commit
3a7f94c590
@ -35,6 +35,7 @@ interface ISkypePuppet {
|
|||||||
client: Client;
|
client: Client;
|
||||||
data: any;
|
data: any;
|
||||||
deletedMessages: ExpireSet<string>;
|
deletedMessages: ExpireSet<string>;
|
||||||
|
restarting: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ISkypePuppets {
|
interface ISkypePuppets {
|
||||||
@ -186,6 +187,10 @@ export class Skype {
|
|||||||
});
|
});
|
||||||
const MINUTE = 60000;
|
const MINUTE = 60000;
|
||||||
client.on("error", async (err: Error) => {
|
client.on("error", async (err: Error) => {
|
||||||
|
if (p.restarting) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
p.restarting = true;
|
||||||
const causeName = (err as any).cause ? (err as any).cause.name : "";
|
const causeName = (err as any).cause ? (err as any).cause.name : "";
|
||||||
log.error("Error when polling");
|
log.error("Error when polling");
|
||||||
log.error("name: ", err.name);
|
log.error("name: ", err.name);
|
||||||
@ -216,6 +221,7 @@ export class Skype {
|
|||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
await client.connect();
|
await client.connect();
|
||||||
|
p.restarting = false;
|
||||||
await this.puppet.setUserId(puppetId, client.username);
|
await this.puppet.setUserId(puppetId, client.username);
|
||||||
p.data.state = client.getState;
|
p.data.state = client.getState;
|
||||||
await this.puppet.setPuppetData(puppetId, p.data);
|
await this.puppet.setPuppetData(puppetId, p.data);
|
||||||
@ -239,6 +245,7 @@ export class Skype {
|
|||||||
client,
|
client,
|
||||||
data,
|
data,
|
||||||
deletedMessages: new ExpireSet(TWO_MIN),
|
deletedMessages: new ExpireSet(TWO_MIN),
|
||||||
|
restarting: false,
|
||||||
};
|
};
|
||||||
await this.startClient(puppetId);
|
await this.startClient(puppetId);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user