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