# Web to Game Events Listner

To listen to events from ArcPlay's web experience, you can use the `window.addEventListener`&#x20;

Here is an example implementation for it:

```javascript
window.addEventListener("message", (event) => {
  if (event.data) {
    switch (event.data.funcName) {
      case "game_pause":
        // Pause code here.
        break;
      case "game_unlock_item":
        const { itemId } = event.data.rewardParams; 
        // Unlock item code here.
        break;
    }
  }
});
```

The data will be in the format `{ funcName: “string”, …other data }` where `funcName` is the name of the event. It can be one of the following:

<table><thead><tr><th width="268">Event Name</th><th>Listening Logic</th></tr></thead><tbody><tr><td><code>game_replay</code></td><td>When the user clicks on “Replay” in ArcPlay's web experience. The game needs to restart so it can be played again</td></tr><tr><td><code>game_unlock_item</code></td><td><p>When the game gets this event, the game must unlock the reward item.</p><p> <br>This will contain the reward parameters with key name <code>rewardParams</code> as an additional parameter. The value of <code>rewardParams</code> will be the same as the value game had sent while calling the game to web event <code>game_reward_click</code></p></td></tr><tr><td><code>game_pause</code></td><td>When the user either leaves ArcPlay or hits the back button on the phone. The game will need to be paused.</td></tr><tr><td><code>game_resume</code></td><td>When the game needs to be resumed from the pause state</td></tr><tr><td><code>game_mute_allsound</code></td><td>When the user leaves ArcPlay or an ad is shown. The game will continue to run in the background, thus needs to be muted</td></tr><tr><td><code>game_restore_allsound</code></td><td>When the game is in the foreground again, the audio must be restored to the state it was in before <code>game_mute_allsound</code> was fired.</td></tr></tbody></table>

