fix some bun related issues

This commit is contained in:
Soph :3 2024-04-28 18:36:36 +03:00
parent 7159558e5e
commit 2c6835e2b3
Signed by: sophie
GPG key ID: EDA5D222A0C270F2
2 changed files with 14 additions and 10 deletions

View file

@ -36,7 +36,7 @@ export class Server {
async start(port: number) { async start(port: number) {
this.server = Bun.listen<{dataBuffer?: Buffer}>({ this.server = Bun.listen<{dataBuffer?: Buffer}>({
hostname: "localhost", hostname: process.env.HOST!,
port: +process.env.PORT!, port: +process.env.PORT!,
socket: { socket: {
data: (socket, data) => { data: (socket, data) => {
@ -67,7 +67,9 @@ export class Server {
open: (socket) => { open: (socket) => {
socket.data = {} socket.data = {}
}, },
close(socket) {}, close: async (socket) => {
await this.removeUser(socket, "Disconnected");
},
drain(socket) {}, drain(socket) {},
error(socket, error) {}, error(socket, error) {},
}, },

View file

@ -8,9 +8,10 @@
2. entierly cloud based (meaning you can host it anywhere) 2. entierly cloud based (meaning you can host it anywhere)
3. extremely extensive plugin system 3. extremely extensive plugin system
4. solid implementation of sockets in deno and how to patch them together 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 1. configure .env file to look something like
@ -20,13 +21,14 @@ HASH=RandomHashIlIke
OPS=["Me"] OPS=["Me"]
ONLINEMODE=true ONLINEMODE=true
MAIN=main MAIN=main
HOST=0.0.0.0
``` ```
NOTE: if you are running inside of a cloud provider, just set these as your NOTE: if you are running inside of a cloud provider, just set these as your
environment variables environment variables
3. install deno 2. install bun
4. run `deno run --allow-env --allow-net --allow-read index.ts` 3. run `bun index.ts`
### insipration taken from: ### insipration taken from:
@ -36,10 +38,10 @@ environment variables
### issues: ### issues:
1. Properly queue up map saves instead of just blantantly saving whenever 1. ~~Properly queue up map saves instead of just blantantly saving whenever
possible 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 2. ~~massive performance issues, running more than 100 something accounts makes
the server instead insane amounts of cpu (most likely multithreading needed) 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 3. no cpe support! i want to get all of the above issues fixed before
implementing CPE support implementing CPE support
4. no IP cooldown connections (no block cooldown either), no anticheat 4. no IP cooldown connections (no block cooldown either), no anticheat