Skip to content

Commit 56e8bf1

Browse files
authored
Merge pull request #25 from metaversecloud-com/dev
Dev
2 parents d7ad8fd + c4777b8 commit 56e8bf1

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

server/controllers/handleRaceStart.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ export const handleRaceStart = async (req, res) => {
1212
redisObj.set(profileId, JSON.stringify({ 0: false }));
1313

1414
const world = World.create(urlSlug, { credentials });
15-
world.triggerActivity({ type: WorldActivityType.GAME_ON, assetId });
15+
world.triggerActivity({ type: WorldActivityType.GAME_ON, assetId }).catch((error) => {
16+
console.error("Error triggering activity:", error);
17+
});
1618

1719
// move visitor to start line asset
1820
const startCheckpoint = (

server/controllers/handleSwitchTrack.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { World, Visitor, errorHandler, getCredentials } from "../utils/index.js"
33
export const handleSwitchTrack = async (req, res) => {
44
try {
55
const credentials = getCredentials(req.query);
6-
const { assetId, profileId, interactiveNonce, interactivePublicKey, urlSlug, visitorId, sceneDropId } = credentials;
6+
const { assetId, profileId, urlSlug, visitorId, sceneDropId } = credentials;
77
const { trackSceneId } = req.query;
88

99
const world = await World.create(urlSlug, { credentials });
@@ -41,6 +41,8 @@ export const handleSwitchTrack = async (req, res) => {
4141
sceneDropId,
4242
});
4343

44+
await visitor.closeIframe(assetId);
45+
4446
const numberOfCheckpoints = await world.fetchDroppedAssetsWithUniqueName({
4547
uniqueName: "race-track-checkpoint",
4648
isPartial: true,
@@ -54,8 +56,6 @@ export const handleSwitchTrack = async (req, res) => {
5456
{ analytics: [{ analyticName: "trackUpdates", profileId, uniqueKey: profileId }] },
5557
);
5658

57-
await visitor.closeIframe(assetId);
58-
5959
return res.json({ success: true });
6060
} catch (error) {
6161
return errorHandler({

server/utils/checkpoints/finishLineEntered.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { timeToValue } from "../utils.js";
44

55
export const finishLineEntered = async ({ credentials, currentElapsedTime, profileObject, raceObject, world }) => {
66
try {
7-
const { profileId, sceneDropId, urlSlug, visitorId } = credentials;
7+
const { profileId, sceneDropId, urlSlug, username, visitorId } = credentials;
88
const { checkpoints, highscore } = profileObject;
99
const allCheckpointsCompleted = raceObject.numberOfCheckpoints === Object.keys(checkpoints).length;
1010

@@ -19,11 +19,15 @@ export const finishLineEntered = async ({ credentials, currentElapsedTime, profi
1919
[`${sceneDropId}.profiles.${profileId}.elapsedTime`]: currentElapsedTime,
2020
[`${sceneDropId}.profiles.${profileId}.startTimestamp`]: null,
2121
[`${sceneDropId}.profiles.${profileId}.highscore`]: newHighscore,
22+
[`${sceneDropId}.profiles.${profileId}.username`]: username,
2223
},
2324
{ analytics: [{ analyticName: "completions", uniqueKey: profileId }] },
2425
);
2526

26-
if (newHighscore !== highscore) world.triggerActivity({ type: WorldActivityType.GAME_HIGH_SCORE, assetId });
27+
if (newHighscore !== highscore)
28+
world.triggerActivity({ type: WorldActivityType.GAME_HIGH_SCORE, assetId }).catch((error) => {
29+
console.error("Error triggering activity:", error);
30+
});
2731

2832
const visitor = await Visitor.get(visitorId, urlSlug, { credentials });
2933
const { x, y } = visitor.moveTo;

0 commit comments

Comments
 (0)