-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlogcat.js
34 lines (32 loc) · 998 Bytes
/
logcat.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
const PORT = 25501;
const io = require("socket.io");
const server = new io.Server(PORT, {
cors: {
origin: /./,
},
});
server.on("connection", socket => {
console.log("Internal: New connection");
socket.on("disconnect", (reason) => {
console.log("Internal: Disconnected:", reason);
});
socket.on("e", (e, data) => {
if (!data) return;
if (e === "ChatRoomMessage") {
if (data.Type === "Chat" || data.Type === "Emote") {
console.log(`Message:${data.Type}:${data.Sender}:${data.Content}`);
} else if (data.Type === "Action") {
let res = `Message:${data.Type}:${data.Content}:${data.Sender}: `;
const DestNumber = data.Dictionary?.find(d => d?.Tag === "DestinationCharacter" || d?.Tag === "DestinationCharacterName")?.MemberNumber;
if (DestNumber) {
res += `Dest:${DestNumber} `;
}
const Asset = data.Dictionary?.find(d => d?.Tag === "AssetName")?.AssetName;
if (Asset) {
res += `Asset:${Asset} `;
}
console.log(res);
}
}
})
});