2021-02-06 17:08:08 +01:00
|
|
|
require("missing-native-js-functions");
|
2021-02-04 10:25:41 +01:00
|
|
|
const WebSocket = require("ws");
|
2021-02-06 17:08:08 +01:00
|
|
|
const Constants = require("./dist/util/Constants");
|
2021-02-04 10:25:41 +01:00
|
|
|
|
2021-04-07 04:01:33 +02:00
|
|
|
// const ws = new WebSocket("ws://127.0.0.1:8080");
|
2021-10-14 19:47:10 +02:00
|
|
|
const ws = new WebSocket("wss://dev.fosscord.com");
|
2021-02-04 10:25:41 +01:00
|
|
|
|
|
|
|
ws.on("open", () => {
|
2021-02-06 17:08:08 +01:00
|
|
|
// ws.send(JSON.stringify({ req_type: "new_auth" }));
|
2021-02-04 10:25:41 +01:00
|
|
|
// ws.send(JSON.stringify({ req_type: "check_auth", token: "" }));
|
|
|
|
// op: 0,
|
|
|
|
// d: {},
|
|
|
|
// s: 42,
|
|
|
|
// t: "GATEWAY_EVENT_NAME",
|
|
|
|
});
|
|
|
|
|
2021-02-06 17:08:08 +01:00
|
|
|
function send(data) {
|
|
|
|
ws.send(JSON.stringify(data));
|
|
|
|
}
|
|
|
|
|
|
|
|
ws.on("message", (buffer) => {
|
|
|
|
let data = JSON.parse(buffer.toString());
|
2021-02-04 10:25:41 +01:00
|
|
|
console.log(data);
|
2021-02-06 17:08:08 +01:00
|
|
|
|
|
|
|
switch (data.op) {
|
|
|
|
case 10:
|
|
|
|
setIntervalNow(() => {
|
|
|
|
send({ op: 1 });
|
|
|
|
}, data.d.heartbeat_interval);
|
|
|
|
|
2021-04-07 04:01:33 +02:00
|
|
|
// send({
|
|
|
|
// op: 2,
|
|
|
|
// d: {
|
|
|
|
// token:
|
|
|
|
// "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjgxMTY0MjkxNzQzMjA2NjA0OCIsImlhdCI6MTYxMzU4MTE1MX0.7Qj_z2lYIgJ0rc7NfGtpW5DKGqecQfv1mLpoBUQHKDc",
|
|
|
|
// intents: 0n,
|
|
|
|
// properties: {},
|
|
|
|
// },
|
|
|
|
// });
|
|
|
|
|
2021-02-06 17:08:08 +01:00
|
|
|
send({
|
2021-04-07 04:01:33 +02:00
|
|
|
op: 6,
|
2021-02-06 17:08:08 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
ws.on("close", (code, reason) => {
|
|
|
|
console.log(code, reason, Constants.CLOSECODES[code]);
|
2021-02-04 10:25:41 +01:00
|
|
|
});
|