From 2c6835e2b3a55930ae6fa6fcb85a2be7edd80681 Mon Sep 17 00:00:00 2001 From: sophie Date: Sun, 28 Apr 2024 18:36:36 +0300 Subject: [PATCH] fix some bun related issues --- classes/Server.ts | 6 ++++-- readme.md | 18 ++++++++++-------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/classes/Server.ts b/classes/Server.ts index d7985af..ad09323 100644 --- a/classes/Server.ts +++ b/classes/Server.ts @@ -36,7 +36,7 @@ export class Server { async start(port: number) { this.server = Bun.listen<{dataBuffer?: Buffer}>({ - hostname: "localhost", + hostname: process.env.HOST!, port: +process.env.PORT!, socket: { data: (socket, data) => { @@ -67,7 +67,9 @@ export class Server { open: (socket) => { socket.data = {} }, - close(socket) {}, + close: async (socket) => { + await this.removeUser(socket, "Disconnected"); + }, drain(socket) {}, error(socket, error) {}, }, diff --git a/readme.md b/readme.md index 17036a5..fefbee3 100644 --- a/readme.md +++ b/readme.md @@ -8,9 +8,10 @@ 2. entierly cloud based (meaning you can host it anywhere) 3. extremely extensive plugin system 4. solid implementation of sockets in deno and how to patch them together -5. DENO!! It's not node, and a classic server. +5. Bun!! It's not node, and a classic server +6. very fast -### setup tutorial (be warned it's not the easiest) +### setup tutorial 1. configure .env file to look something like @@ -20,13 +21,14 @@ HASH=RandomHashIlIke OPS=["Me"] ONLINEMODE=true MAIN=main +HOST=0.0.0.0 ``` NOTE: if you are running inside of a cloud provider, just set these as your environment variables -3. install deno -4. run `deno run --allow-env --allow-net --allow-read index.ts` +2. install bun +3. run `bun index.ts` ### insipration taken from: @@ -36,10 +38,10 @@ environment variables ### issues: -1. Properly queue up map saves instead of just blantantly saving whenever - possible -2. massive performance issues, running more than 100 something accounts makes - the server instead insane amounts of cpu (most likely multithreading needed) +1. ~~Properly queue up map saves instead of just blantantly saving whenever + possible~~ it now saves to disk, IO is very fast and shouldn't cause issues anymore +2. ~~massive performance issues, running more than 100 something accounts makes + the server instead insane amounts of cpu (most likely multithreading needed)~~ the server is now async so it's way quicker (untested) 3. no cpe support! i want to get all of the above issues fixed before implementing CPE support 4. no IP cooldown connections (no block cooldown either), no anticheat