Add Socketio support

and modify some websocket and sse code to pick up common function and component
This commit is contained in:
moonrailgun
2020-03-04 14:40:44 +08:00
parent d6fd01d210
commit 14701369bd
7 changed files with 562 additions and 87 deletions

12
functions/utils/string.js Normal file
View File

@@ -0,0 +1,12 @@
export function getSourcePrefix(source) {
const sourceEmojis = {
// Source used for info messages.
info: "\t [INFO]:\t",
// Source used for client to server messages.
client: "\t👽 [SENT]:\t",
// Source used for server to client messages.
server: "\t📥 [RECEIVED]:\t",
}
if (Object.keys(sourceEmojis).includes(source)) return sourceEmojis[source]
return ""
}