Refreshing map URL (#2144)
* Refreshing map URL When a "refresh" message is sent from the admin to the pusher, the map details endpoint is now called again. If the Map URL is changed, the variable manager is refreshed.
This commit is contained in:
parent
d6450831c6
commit
5e156ade74
@ -520,7 +520,16 @@ export class GameRoom {
|
||||
this.admins.delete(admin);
|
||||
}
|
||||
|
||||
public incrementVersion(): number {
|
||||
public async incrementVersion(): Promise<number> {
|
||||
// Let's check if the mapUrl has changed
|
||||
const mapDetails = await GameRoom.getMapDetails(this.roomUrl);
|
||||
if (this.mapUrl !== mapDetails.mapUrl) {
|
||||
this.mapUrl = mapDetails.mapUrl;
|
||||
this.mapPromise = undefined;
|
||||
// Reset the variable manager
|
||||
this.variableManagerPromise = undefined;
|
||||
}
|
||||
|
||||
this.versionNumber++;
|
||||
return this.versionNumber;
|
||||
}
|
||||
|
@ -852,14 +852,14 @@ export class SocketManager {
|
||||
return;
|
||||
}
|
||||
|
||||
const versionNumber = room.incrementVersion();
|
||||
const versionNumber = await room.incrementVersion();
|
||||
room.getUsers().forEach((recipient) => {
|
||||
const worldFullMessage = new RefreshRoomMessage();
|
||||
worldFullMessage.setRoomid(roomId);
|
||||
worldFullMessage.setVersionnumber(versionNumber);
|
||||
const refreshRoomMessage = new RefreshRoomMessage();
|
||||
refreshRoomMessage.setRoomid(roomId);
|
||||
refreshRoomMessage.setVersionnumber(versionNumber);
|
||||
|
||||
const clientMessage = new ServerToClientMessage();
|
||||
clientMessage.setRefreshroommessage(worldFullMessage);
|
||||
clientMessage.setRefreshroommessage(refreshRoomMessage);
|
||||
|
||||
recipient.socket.write(clientMessage);
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user