problèmes du jeu réglés en grosse partie
This commit is contained in:
@@ -96,8 +96,7 @@ async function clientAnnounceListener(this: WebSocket, data: string)
|
||||
const player = clientsMap.get(this.id) as ClientPlayer;
|
||||
player.matchOptions = announce.matchOptions;
|
||||
player.token = announce.token;
|
||||
player.username = announce.username;
|
||||
|
||||
announce.isInvitedPerson ? player.username = announce.playerTwoUsername : player.username = announce.username;
|
||||
this.send(JSON.stringify( new ev.EventAssignId(this.id) )); // unused
|
||||
this.send(JSON.stringify( new ev.ServerEvent(en.EventTypes.matchmakingInProgress) ));
|
||||
if (announce.privateMatch) {
|
||||
@@ -173,7 +172,7 @@ function privateMatchmaking(player: ClientPlayer)
|
||||
const compatiblePlayers: ClientPlayer[] = [];
|
||||
for (const [id, client] of privateMatchmakingMap)
|
||||
{
|
||||
if (client.token === token && client.username !== player.username)
|
||||
if (client.token === token)
|
||||
{
|
||||
compatiblePlayers.push(client);
|
||||
if (compatiblePlayers.length === maxPlayersNumber) {
|
||||
@@ -189,11 +188,20 @@ function privateMatchmaking(player: ClientPlayer)
|
||||
createGameSession(compatiblePlayers, matchOptions);
|
||||
}
|
||||
else {
|
||||
setTimeout(function abortMatch() {
|
||||
setTimeout(async function abortMatch() {
|
||||
if (!player.gameSession)
|
||||
{
|
||||
// TODO: informe le back de l'invalidité du token d'invitation
|
||||
player.socket.send(JSON.stringify( new ev.EventMatchAbort() ));
|
||||
const responseTobakc = await fetch(c.addressBackEnd + "/game/gameserver/destroysession",{
|
||||
method: "POST",
|
||||
headers : {"Content-Type": "application/json"},
|
||||
body : JSON.stringify({
|
||||
token : player.token
|
||||
})
|
||||
})
|
||||
.then(x => x.json())
|
||||
.catch(error => console.log("ERROR : " + error))
|
||||
clientTerminate(player);
|
||||
}
|
||||
}, 60000);
|
||||
|
||||
@@ -72,7 +72,7 @@ export class EventMatchEnd extends ServerEvent {
|
||||
}
|
||||
|
||||
export class EventMatchAbort extends ServerEvent {
|
||||
|
||||
|
||||
constructor() {
|
||||
super(en.EventTypes.matchAbort);
|
||||
}
|
||||
@@ -102,12 +102,16 @@ export class ClientAnnouncePlayer extends ClientAnnounce {
|
||||
username: string;
|
||||
privateMatch: boolean;
|
||||
playerTwoUsername?: string;
|
||||
constructor(matchOptions: en.MatchOptions, token: string, username: string, privateMatch: boolean = false, playerTwoUsername?: string) {
|
||||
isInvitedPerson? : boolean;
|
||||
constructor(matchOptions: en.MatchOptions, token: string, username: string, privateMatch: boolean = false, playerTwoUsername?: string, isInvitedPerson? : boolean) {
|
||||
super(en.ClientRole.player);
|
||||
this.matchOptions = matchOptions;
|
||||
this.token = token;
|
||||
this.username = username;
|
||||
this.privateMatch = privateMatch;
|
||||
if (isInvitedPerson) {
|
||||
this.isInvitedPerson = isInvitedPerson;
|
||||
}
|
||||
if (playerTwoUsername) {
|
||||
this.playerTwoUsername = playerTwoUsername;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user