mirror of
https://github.com/tiramisulabs/seyfert.git
synced 2025-07-03 05:26:07 +00:00
fix: ws priority
This commit is contained in:
parent
f70edcd7e9
commit
b9117f5524
10
package-lock.json
generated
10
package-lock.json
generated
@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "seyfert",
|
"name": "seyfert",
|
||||||
"version": "1.2.0",
|
"version": "1.2.1",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "seyfert",
|
"name": "seyfert",
|
||||||
"version": "1.2.0",
|
"version": "1.2.1",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"chokidar": "^3.6.0",
|
"chokidar": "^3.6.0",
|
||||||
@ -997,9 +997,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/discord-api-types": {
|
"node_modules/discord-api-types": {
|
||||||
"version": "0.37.77",
|
"version": "0.37.78",
|
||||||
"resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.37.77.tgz",
|
"resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.37.78.tgz",
|
||||||
"integrity": "sha512-AkEn9nZA5w/XJ8wzKzlpx3X+MToQCowKahftF1+KYnMWnuglCrVRojy1XlIWX8Frgp1v8INceGKpvDkbvMLJ4g=="
|
"integrity": "sha512-IJdyOPhq7r9Gw5/4X9u4vG8rX7+AwOtX7flUSQyQ1vAZzlnN452GGElUPmjQJIo8gB5VwMesbA9eMW+f0NMWVA=="
|
||||||
},
|
},
|
||||||
"node_modules/dot-prop": {
|
"node_modules/dot-prop": {
|
||||||
"version": "5.3.0",
|
"version": "5.3.0",
|
||||||
|
@ -148,7 +148,7 @@ export class WorkerClient<Ready extends boolean = boolean> extends BaseClient {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
await shard.send({
|
await shard.send(true, {
|
||||||
...data,
|
...data,
|
||||||
} satisfies GatewaySendPayload);
|
} satisfies GatewaySendPayload);
|
||||||
|
|
||||||
|
@ -97,7 +97,7 @@ export class Shard {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
async send<T extends GatewaySendPayload = GatewaySendPayload>(message: T) {
|
async send<T extends GatewaySendPayload = GatewaySendPayload>(force: boolean, message: T) {
|
||||||
this.debugger?.info(
|
this.debugger?.info(
|
||||||
`[Shard #${this.id}] Sending: ${GatewayOpcodes[message.op]} ${JSON.stringify(
|
`[Shard #${this.id}] Sending: ${GatewayOpcodes[message.op]} ${JSON.stringify(
|
||||||
message.d,
|
message.d,
|
||||||
@ -112,14 +112,14 @@ export class Shard {
|
|||||||
1,
|
1,
|
||||||
)}`,
|
)}`,
|
||||||
);
|
);
|
||||||
await this.checkOffline();
|
await this.checkOffline(force);
|
||||||
await this.bucket.acquire();
|
await this.bucket.acquire(force);
|
||||||
await this.checkOffline();
|
await this.checkOffline(force);
|
||||||
this.websocket?.send(JSON.stringify(message));
|
this.websocket?.send(JSON.stringify(message));
|
||||||
}
|
}
|
||||||
|
|
||||||
async identify() {
|
async identify() {
|
||||||
await this.send({
|
await this.send(true, {
|
||||||
op: GatewayOpcodes.Identify,
|
op: GatewayOpcodes.Identify,
|
||||||
d: {
|
d: {
|
||||||
token: `Bot ${this.options.token}`,
|
token: `Bot ${this.options.token}`,
|
||||||
@ -137,7 +137,7 @@ export class Shard {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async resume() {
|
async resume() {
|
||||||
await this.send({
|
await this.send(true, {
|
||||||
op: GatewayOpcodes.Resume,
|
op: GatewayOpcodes.Resume,
|
||||||
d: {
|
d: {
|
||||||
seq: this.data.resumeSeq!,
|
seq: this.data.resumeSeq!,
|
||||||
@ -306,9 +306,9 @@ export class Shard {
|
|||||||
return this.onpacket(JSON.parse(data as string));
|
return this.onpacket(JSON.parse(data as string));
|
||||||
}
|
}
|
||||||
|
|
||||||
checkOffline() {
|
checkOffline(force: boolean) {
|
||||||
if (!this.isOpen) {
|
if (!this.isOpen) {
|
||||||
return new Promise(resolve => this.offlineSendQueue.push(resolve));
|
return new Promise(resolve => this.offlineSendQueue[force ? 'unshift' : 'push'](resolve));
|
||||||
}
|
}
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
@ -198,6 +198,6 @@ export class ShardManager extends Map<number, Shard> {
|
|||||||
payload,
|
payload,
|
||||||
} satisfies WatcherSendToShard);
|
} satisfies WatcherSendToShard);
|
||||||
}
|
}
|
||||||
this.get(shardId)?.send(payload);
|
this.get(shardId)?.send(false, payload);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -66,9 +66,9 @@ export class DynamicBucket {
|
|||||||
this.processing = false;
|
this.processing = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
acquire() {
|
acquire(force = false) {
|
||||||
return new Promise(res => {
|
return new Promise(res => {
|
||||||
this.queue.push(res);
|
this.queue[force ? 'unshift' : 'push'](res);
|
||||||
void this.processQueue();
|
void this.processQueue();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user