Compare commits
2 Commits
497e52be38
...
b161a29909
Author | SHA1 | Date |
---|---|---|
|
b161a29909 | |
|
e87e6d47f9 |
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "schat2-clive",
|
||||
"version": "1.5.19",
|
||||
"version": "1.6.0",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "schat2-clive",
|
||||
"version": "1.5.19",
|
||||
"version": "1.6.0",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"bhttp": "^1.2.8",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "schat2-clive",
|
||||
"version": "1.5.19",
|
||||
"version": "1.6.0",
|
||||
"description": "Game host for SChat 2-powered chat sites",
|
||||
"main": "src/app.js",
|
||||
"scripts": {
|
||||
|
|
17
src/app.js
17
src/app.js
|
@ -260,10 +260,16 @@ function handleError(error, socket, domain, data) {
|
|||
}
|
||||
}
|
||||
|
||||
async function connect(wsCreds, sessionCookie, bot, games) {
|
||||
async function connect(bot, games) {
|
||||
const socket = { ws: { readyState: 0 } };
|
||||
|
||||
socket.connect = () => {
|
||||
socket.connect = async () => {
|
||||
const { user, httpSession, sessionCookie } = await auth();
|
||||
const wsCreds = await getWsId(httpSession);
|
||||
|
||||
bot.user = user;
|
||||
bot.httpSession = httpSession;
|
||||
|
||||
logger.info(`Attempting to connect to ${config.socket}`);
|
||||
|
||||
socket.ws = new WebSocket(`${config.socket}?${new URLSearchParams({ v: wsCreds.wsId, t: wsCreds.timestamp }).toString()}`, [], {
|
||||
|
@ -310,19 +316,14 @@ async function connect(wsCreds, sessionCookie, bot, games) {
|
|||
}
|
||||
|
||||
async function init() {
|
||||
const { user, httpSession, sessionCookie } = await auth();
|
||||
const wsCreds = await getWsId(httpSession);
|
||||
|
||||
const bot = {
|
||||
user,
|
||||
httpSession,
|
||||
rooms: [],
|
||||
users: [],
|
||||
};
|
||||
|
||||
const games = getGames(bot);
|
||||
|
||||
bot.socket = await connect(wsCreds, sessionCookie, bot, games);
|
||||
bot.socket = await connect(bot, games);
|
||||
|
||||
await initPoints();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue