-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathxboxConsole.js
64 lines (59 loc) · 1.37 KB
/
xboxConsole.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import net from "net";
const s = net.Socket();
export default class XboxConsole {
constructor(ip, port = 730) {
s.connect(
port,
ip
);
this.socket = s;
this.readData = [];
s.on("data", function(data) {
this.readData.push(data);
console.log("DATA " + s.remoteAddress + ": " + data);
});
}
sendCommand(command) {
this.socket.write(command + "\r\n");
}
setMemory(address, data) {
this.sendCommand(`setmem addr=${address} data=${data}`);
}
/* Couldn't test this */
getMemory(address, rlength) {
let _tempLength = this.readData.length;
this.sendCommand(`getmemex addr=${address} length=${rlength}`);
let _data = this.readData.slice(_tempLength, _tempLength + rlength);
return _data;
}
xNotify(message, type = "PLAIN") {
let String = 2;
let Int = 1;
let command =
"consolefeatures ver=2" +
' type=12 params="A\\0\\A\\2\\' +
String +
"/" +
message.length +
"\\" +
Buffer.from(message, "utf8").toString("hex") +
"\\" +
Int +
"\\";
switch (type) {
case "PLAIN":
command += '0\\"';
break;
case "INVITE":
command += '1\\"';
break;
case "FRIEND":
command += '2\\"';
break;
default:
command += '0\\"';
break;
}
this.sendCommand(command);
}
}