2022-11-23 00:48:28 +00:00
|
|
|
import { SharedContent } from "../interfaces/SharedContent";
|
2022-11-19 01:06:03 +00:00
|
|
|
import { User } from "../objects/User";
|
|
|
|
const osu = require("osu-packet");
|
|
|
|
|
2022-11-21 23:26:20 +00:00
|
|
|
export function UserPresenceBundle(arg0:User | SharedContent) : Buffer {
|
2022-11-19 01:06:03 +00:00
|
|
|
const osuPacketWriter = new osu.Bancho.Writer;
|
2022-11-21 23:26:20 +00:00
|
|
|
let sharedContent:SharedContent;
|
|
|
|
if (arg0 instanceof User) {
|
|
|
|
sharedContent = arg0.sharedContent;
|
|
|
|
} else {
|
|
|
|
sharedContent = arg0;
|
|
|
|
}
|
2022-11-19 01:06:03 +00:00
|
|
|
|
|
|
|
let userIds:Array<number> = new Array<number>();
|
|
|
|
|
2022-11-21 23:26:20 +00:00
|
|
|
for (let userData of sharedContent.users.getIterableItems()) {
|
2022-11-19 01:06:03 +00:00
|
|
|
userIds.push(userData.id);
|
|
|
|
}
|
|
|
|
|
|
|
|
osuPacketWriter.UserPresenceBundle(userIds);
|
|
|
|
|
2022-11-21 23:26:20 +00:00
|
|
|
if (arg0 instanceof User) {
|
|
|
|
arg0.addActionToQueue(osuPacketWriter.toBuffer);
|
|
|
|
}
|
|
|
|
|
|
|
|
return osuPacketWriter.toBuffer;
|
2022-11-19 01:06:03 +00:00
|
|
|
}
|