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 = []
|
||||
|
||||
|
||||
wsServer = WebSocket.Server;
|
||||
|
||||
let server = require('http').createServer()
|
||||
|
@ -54,6 +55,7 @@ wsServer = new wsServer({
|
|||
server.on('request', app)
|
||||
|
||||
wsServer.on("connection", function connection(socket) {
|
||||
console.log("BALLS")
|
||||
socket.on('message', function message(data) {
|
||||
data = JSON.parse(data)
|
||||
if (data.op == 3) {
|
||||
|
@ -72,10 +74,10 @@ wsServer.on("connection", function connection(socket) {
|
|||
socket.send(`{ "op": 1 }`)
|
||||
|
||||
sockets.push({ socket, lastPing: Date.now() })
|
||||
|
||||
})
|
||||
|
||||
|
||||
|
||||
process.on('uncaughtException', (err, origin) => {
|
||||
fs.writeSync(
|
||||
process.stderr.fd,
|
||||
|
|
|
@ -45,8 +45,8 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<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>
|
||||
<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>
|
||||
<hr>
|
||||
<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>
|
||||
|
@ -58,7 +58,6 @@
|
|||
<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>
|
||||
</div>
|
||||
<br>
|
||||
{CUSTOM_STATUS}
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -58,14 +58,16 @@ window.onload = function () {
|
|||
}
|
||||
}
|
||||
|
||||
function socketeer() {
|
||||
var lanyard = new WebSocket('wss://beta.violets-purgatory.dev')
|
||||
var lastPong = Date.now()
|
||||
|
||||
lanyard.onerror = (error) => {
|
||||
function socketeer() {
|
||||
var sock = new WebSocket('wss://beta.violets-purgatory.dev')
|
||||
|
||||
sock.onerror = (error) => {
|
||||
console.log(error)
|
||||
}
|
||||
|
||||
lanyard.onclose = () => {
|
||||
sock.onclose = () => {
|
||||
console.log("Connection Closed. Attempting Reconnect in 30 seconds.")
|
||||
setTimeout(() => {
|
||||
socketeer()
|
||||
|
@ -73,19 +75,19 @@ function socketeer() {
|
|||
}
|
||||
|
||||
function ping(dur) {
|
||||
lanyard.send(JSON.stringify({
|
||||
sock.send(JSON.stringify({
|
||||
op: 3
|
||||
}))
|
||||
setTimeout(() => {
|
||||
ping(dur)
|
||||
if (Date.now() - lastPong > 120000) {
|
||||
lanyard.close()
|
||||
sock.close()
|
||||
console.log("Max duration since last pong exceeded- Closing socket.")
|
||||
}
|
||||
}, dur);
|
||||
}
|
||||
|
||||
lanyard.addEventListener("message", async (res) => {
|
||||
sock.addEventListener("message", async (res) => {
|
||||
var data = JSON.parse(res.data)
|
||||
if (data.op == 1) {
|
||||
console.log("Connected to Discord Websocket!")
|
||||
|
|
Loading…
Reference in a new issue