summary refs log tree commit diff
path: root/src/Server.ts
diff options
context:
space:
mode:
authorFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-06-24 08:51:39 +0200
committerFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-06-24 08:51:39 +0200
commit4fc395823d28401a2631bb8ad788f06b980078ca (patch)
tree679172ef2395cd4c58a11d9e5ca8e3f4442c8c87 /src/Server.ts
parentInitial commit (diff)
downloadserver-4fc395823d28401a2631bb8ad788f06b980078ca.tar.xz
:construction: init
Diffstat (limited to '')
-rw-r--r--src/Server.ts43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/Server.ts b/src/Server.ts
new file mode 100644

index 00000000..bb82e659 --- /dev/null +++ b/src/Server.ts
@@ -0,0 +1,43 @@ +import { Server as WebSocketServer } from "ws"; +import { Config, db } from "@fosscord/server-util"; +import mediasoup from "mediasoup" + +var port = Number(process.env.PORT); +if (isNaN(port)) port = 3004; + +export class Server { + public ws: WebSocketServer; + public turn: any; + + constructor() { + this.ws = new WebSocketServer({ + port, + maxPayload: 4096, + }); + this.ws.on("connection", (socket) => { + socket.on("message", (message) => { + socket.emit( + JSON.stringify({ + op: 2, + d: { + ssrc: 1, + ip: "127.0.0.1", + port: 3004, + modes: ["xsalsa20_poly1305", "xsalsa20_poly1305_suffix", "xsalsa20_poly1305_lite"], + heartbeat_interval: 1, + }, + }) + ); + }); + }); + + } + + async listen(): Promise<void> { + // @ts-ignore + await (db as Promise<Connection>); + await Config.init(); + console.log("[DB] connected"); + console.log(`[WebRTC] online on 0.0.0.0:${port}`); + } +}