summary refs log tree commit diff
path: root/gateway/src/util
diff options
context:
space:
mode:
authorFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-09-02 21:11:08 +0200
committerFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-09-02 21:11:08 +0200
commit7eb20464afbc6fcbedef4988617784aa7abf2b3b (patch)
treeca03fd8ff7d568428dcd8fc3e4f3134f211ea98d /gateway/src/util
parent:sparkles: add user_id field to Member (diff)
parentMerge pull request #306 from AlTech98/master (diff)
downloadserver-7eb20464afbc6fcbedef4988617784aa7abf2b3b.tar.xz
Merge branch 'master' of https://github.com/fosscord/fosscord-api
Diffstat (limited to 'gateway/src/util')
-rw-r--r--gateway/src/util/SessionUtils.ts11
-rw-r--r--gateway/src/util/WebSocket.ts1
2 files changed, 12 insertions, 0 deletions
diff --git a/gateway/src/util/SessionUtils.ts b/gateway/src/util/SessionUtils.ts
new file mode 100644

index 00000000..c66c7e76 --- /dev/null +++ b/gateway/src/util/SessionUtils.ts
@@ -0,0 +1,11 @@ +export function genSessionId() { + return genRanHex(32); +} + +export function genVoiceToken() { + return genRanHex(16); +} + +function genRanHex(size: number) { + return [...Array(size)].map(() => Math.floor(Math.random() * 16).toString(16)).join(""); +} diff --git a/gateway/src/util/WebSocket.ts b/gateway/src/util/WebSocket.ts
index d1e13555..2c763743 100644 --- a/gateway/src/util/WebSocket.ts +++ b/gateway/src/util/WebSocket.ts
@@ -6,6 +6,7 @@ import { Channel } from "amqplib"; interface WebSocket extends WS { version: number; user_id: string; + session_id: string; encoding: "etf" | "json"; compress?: "zlib-stream"; shard_count?: bigint;