fix integration with caht service
This commit is contained in:
parent
fd572707ff
commit
19cae8ae63
3 changed files with 12 additions and 12 deletions
|
|
@ -20,7 +20,7 @@ import { sendProfil } from './chatBackHelperFunctions/sendProfil';
|
|||
import { setGameLink } from './setGameLink';
|
||||
import { list_SocketListener } from './chatBackHelperFunctions/list_SocketListener';
|
||||
import { isUser_BlockedBy_me } from './chatBackHelperFunctions/isUser_BlockedBy_me';
|
||||
import type { inviteUserTOGame, ClientInfo, blockedUnBlocked } from './chat_types';
|
||||
import type { ClientInfo, blockedUnBlocked } from './chat_types';
|
||||
import { PongGameId } from '@shared/database/mixin/pong';
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import { PongGameId } from '@shared/database/mixin/pong';
|
|||
export async function setGameLink(fastify: FastifyInstance, data: string): Promise<PongGameId | undefined> {
|
||||
const profilInvite: ClientProfil = JSON.parse(data) || '';
|
||||
|
||||
const payload = { 'user1': `'${profilInvite.SenderID}'`, 'user2':`'${profilInvite.userID}'` };
|
||||
const payload = { 'user1': profilInvite.SenderID, 'user2':profilInvite.userID };
|
||||
try {
|
||||
const resp = await fetch('http://app-pong/api/pong/createPausedGame', {
|
||||
method: 'POST',
|
||||
|
|
@ -14,7 +14,6 @@ export async function setGameLink(fastify: FastifyInstance, data: string): Promi
|
|||
body: JSON.stringify(payload),
|
||||
});
|
||||
if (!resp.ok) {
|
||||
fastify.log.info("HELLO ?");
|
||||
throw (resp);
|
||||
}
|
||||
else {
|
||||
|
|
|
|||
|
|
@ -223,12 +223,8 @@ class StateI {
|
|||
}
|
||||
|
||||
public newPausedGame(suid1: string, suid2: string): GameId | undefined {
|
||||
|
||||
this.fastify.log.info('suid1:' + suid1);
|
||||
this.fastify.log.info('suid2:' + suid2);
|
||||
// if (!this.fastify.db.getUser(suid1) || !this.fastify.db.getUser(suid2)) {
|
||||
// return undefined;
|
||||
// }
|
||||
this.fastify.log.info('new game request: suid1: ' + suid1 + '\tsuid2: ' + suid2);
|
||||
if (!this.fastify.db.getUser(suid1) || !this.fastify.db.getUser(suid2)) { return undefined; }
|
||||
this.fastify.log.info('new paused start');
|
||||
const uid1: UserId = suid1 as UserId;
|
||||
const uid2: UserId = suid2 as UserId;
|
||||
|
|
@ -380,13 +376,18 @@ class StateI {
|
|||
private tryJoinGame(g_id : string, sock : SSocket) : JoinRes {
|
||||
const game_id : PongGameId = g_id as PongGameId;
|
||||
|
||||
if (this.games.has(game_id) === false) { return (JoinRes.no); }
|
||||
if (this.games.has(game_id) === false) {
|
||||
this.fastify.log.warn('gameId:' + g_id + ' is unknown!');
|
||||
return (JoinRes.no);
|
||||
}
|
||||
const game : Pong = this.games.get(game_id)!;
|
||||
if (game.local || (game.userLeft !== sock.authUser.id && game.userRight !== sock.authUser.id)) {
|
||||
if (game.local === true || (game.userLeft !== sock.authUser.id && game.userRight !== sock.authUser.id)) {
|
||||
this.fastify.log.warn('user trying to connect to a game he\'s not part of: gameId:' + g_id + ' userId:' + sock.authUser.id);
|
||||
return (JoinRes.no);
|
||||
}
|
||||
game.userOnPage[game.userLeft === sock.authUser.id ? 0 : 1] = true;
|
||||
if (game.userOnPage[0] === game.userOnPage[1]) {
|
||||
this.fastify.log.info('Paused game start: gameId:' + g_id);
|
||||
this.initGame(game, game_id, game.userLeft, game.userRight);
|
||||
}
|
||||
return (JoinRes.yes);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue