logging ?!
This commit is contained in:
parent
980be6f21e
commit
32c6532a4f
3 changed files with 14 additions and 11 deletions
4
index.js
4
index.js
|
@ -42,6 +42,7 @@ app.use(pageUpdater.middleWare)
|
||||||
|
|
||||||
var sockets = []
|
var sockets = []
|
||||||
|
|
||||||
|
|
||||||
wsServer = WebSocket.Server;
|
wsServer = WebSocket.Server;
|
||||||
|
|
||||||
let server = require('http').createServer()
|
let server = require('http').createServer()
|
||||||
|
@ -54,6 +55,7 @@ wsServer = new wsServer({
|
||||||
server.on('request', app)
|
server.on('request', app)
|
||||||
|
|
||||||
wsServer.on("connection", function connection(socket) {
|
wsServer.on("connection", function connection(socket) {
|
||||||
|
console.log("BALLS")
|
||||||
socket.on('message', function message(data) {
|
socket.on('message', function message(data) {
|
||||||
data = JSON.parse(data)
|
data = JSON.parse(data)
|
||||||
if (data.op == 3) {
|
if (data.op == 3) {
|
||||||
|
@ -72,10 +74,10 @@ wsServer.on("connection", function connection(socket) {
|
||||||
socket.send(`{ "op": 1 }`)
|
socket.send(`{ "op": 1 }`)
|
||||||
|
|
||||||
sockets.push({ socket, lastPing: Date.now() })
|
sockets.push({ socket, lastPing: Date.now() })
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
process.on('uncaughtException', (err, origin) => {
|
process.on('uncaughtException', (err, origin) => {
|
||||||
fs.writeSync(
|
fs.writeSync(
|
||||||
process.stderr.fd,
|
process.stderr.fd,
|
||||||
|
|
|
@ -45,8 +45,8 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<p class="spinnyCount" style="display: none;"">You have spun Violet <span class="localSpins">4</span> times!<br>
|
<p class="spinnyCount" style="display: none;">You have spun Violet <span class="localSpins">4</span> times!<br>
|
||||||
Everyone has spun Violet <span class="globalSpins">3603250</span>+ times!</p>
|
Everyone has spun Violet <span class="globalSpins">3603250</span> times!</p>
|
||||||
<hr>
|
<hr>
|
||||||
<div>
|
<div>
|
||||||
<p style="padding: 10px;">Hi! I'm Violet, a 15 year old web and game developer. I make server-sided dynamic websites, with no Javascript required! I'm currently making games in the Godot Engine, and my dynamic sites in NodeJS.</p>
|
<p style="padding: 10px;">Hi! I'm Violet, a 15 year old web and game developer. I make server-sided dynamic websites, with no Javascript required! I'm currently making games in the Godot Engine, and my dynamic sites in NodeJS.</p>
|
||||||
|
@ -58,7 +58,6 @@
|
||||||
<a class="chip" href="https://{BRANCH_SUB}violets-purgatory.dev">{BRANCH_NAME} site</a>
|
<a class="chip" href="https://{BRANCH_SUB}violets-purgatory.dev">{BRANCH_NAME} site</a>
|
||||||
<a class="chip" href="https://fs.violets-purgatory.dev">FileShare</a>
|
<a class="chip" href="https://fs.violets-purgatory.dev">FileShare</a>
|
||||||
</div>
|
</div>
|
||||||
<br>
|
|
||||||
{CUSTOM_STATUS}
|
{CUSTOM_STATUS}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -58,14 +58,16 @@ window.onload = function () {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function socketeer() {
|
var lastPong = Date.now()
|
||||||
var lanyard = new WebSocket('wss://beta.violets-purgatory.dev')
|
|
||||||
|
|
||||||
lanyard.onerror = (error) => {
|
function socketeer() {
|
||||||
|
var sock = new WebSocket('wss://beta.violets-purgatory.dev')
|
||||||
|
|
||||||
|
sock.onerror = (error) => {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
}
|
}
|
||||||
|
|
||||||
lanyard.onclose = () => {
|
sock.onclose = () => {
|
||||||
console.log("Connection Closed. Attempting Reconnect in 30 seconds.")
|
console.log("Connection Closed. Attempting Reconnect in 30 seconds.")
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
socketeer()
|
socketeer()
|
||||||
|
@ -73,19 +75,19 @@ function socketeer() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function ping(dur) {
|
function ping(dur) {
|
||||||
lanyard.send(JSON.stringify({
|
sock.send(JSON.stringify({
|
||||||
op: 3
|
op: 3
|
||||||
}))
|
}))
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
ping(dur)
|
ping(dur)
|
||||||
if (Date.now() - lastPong > 120000) {
|
if (Date.now() - lastPong > 120000) {
|
||||||
lanyard.close()
|
sock.close()
|
||||||
console.log("Max duration since last pong exceeded- Closing socket.")
|
console.log("Max duration since last pong exceeded- Closing socket.")
|
||||||
}
|
}
|
||||||
}, dur);
|
}, dur);
|
||||||
}
|
}
|
||||||
|
|
||||||
lanyard.addEventListener("message", async (res) => {
|
sock.addEventListener("message", async (res) => {
|
||||||
var data = JSON.parse(res.data)
|
var data = JSON.parse(res.data)
|
||||||
if (data.op == 1) {
|
if (data.op == 1) {
|
||||||
console.log("Connected to Discord Websocket!")
|
console.log("Connected to Discord Websocket!")
|
||||||
|
|
Loading…
Reference in a new issue