Chérif et Luke coop, invitations fix et timeout

This commit is contained in:
LuckyLaszlo
2022-12-22 13:17:20 +01:00
parent 7de9f3a9f1
commit d172f418a3
7 changed files with 55 additions and 18 deletions

View File

@@ -7,6 +7,7 @@
import * as enumeration from './shared_js/enums';
import * as pong from "./client/pong"
import * as pongSpectator from "./client/pongSpectator" // TODO init spectator
import { matchEnded, matchAbort } from "./client/ws";
//user's stuff
let user;
@@ -102,7 +103,8 @@
if (invitation.token)
{
options.playerOneUsername = invitation.playerOneUsername;
options.playerTwoUsername = user.username;
options.playerTwoUsername = invitation.playerTwoUsername;
options.isSomeoneIsInvited = true;
pong.init(options, gameAreaId, invitation.token);
showWaitPage = false
hiddenGame = false;
@@ -148,7 +150,7 @@
console.log(error)
})
showInvitation()
showInvitation() // maybe useless
initGameForPrivateParty(invitation)
}
</script>
@@ -268,6 +270,9 @@
#game_page {
margin: 0;
background-color: #222425;
position: relative;
width: 100%;
height: 100%;
}
#canvas_container {
margin-top: 20px;

View File

@@ -53,6 +53,13 @@ export function init(options: InitOptions, gameAreaId: string, token: string)
export function destroy()
{
// TODO
if (pong)
{
clearInterval(pong.handleInputInterval);
clearInterval(pong.gameLoopInterval);
clearInterval(pong.drawLoopInterval);
initPong(null);
}
}
function start()

View File

@@ -11,6 +11,7 @@ import { sleep } from "./utils.js";
import { Vector, VectorInteger } from "../shared_js/class/Vector.js";
export let matchEnded = false;
export let matchAbort = false;
class ClientInfo {
id = "";
@@ -87,6 +88,7 @@ function preMatchListener(this: WebSocket, event: MessageEvent)
startFunction();
break;
case en.EventTypes.matchAbort:
matchAbort = true;
socket.removeEventListener("message", preMatchListener);
msg.matchAbort();
break;

View File

@@ -71,6 +71,13 @@ export class EventMatchEnd extends ServerEvent {
}
}
export class EventMatchAbort extends ServerEvent {
constructor() {
super(en.EventTypes.matchAbort);
}
}
/* From Client */
export class ClientEvent {