0

I'm trying to implement the GameManagerInterface and add it to GameManager but I always get the next error:

Uncaught Error: Missing listener method for player_available event.cast.receiver.games.j.hk @ cast_games_receiver.js:249

And this is my code:

function GameManagerListener(){};
/*
 *  Fired when the game manager receives a request that changes game data (e.g. 
 *  cast.receiver.games.GameManagerReceiverClient.sendGameDataRequest). 
 *  
 *  @param {Event} _event Event used by cast.receiver.games.GameManager.
 */
GameManagerListener.prototype.onGameDataChanged = function(_event) {
    console.info("[gameManagerListener][onGameDataChanged]");
    console.info(_event);
};

/*
 *  Fired when the game manager receives a request that changes gameplay 
 *  state to cast.receiver.games.GameplayState.LOADING.
 * 
 *  @param {Event} _event Event used by cast.receiver.games.GameManager.
 */
GameManagerListener.prototype.onGameLoading = function(_event) {
    console.info("[gameManagerListener][onGameLoading]");
    console.info(_event);
};

/*
 *  Fired when the game manager receives a game message (e.g. from 
 *  cast.receiver.games.GameManagerReceiverClient.sendGameMessage). 
 *  
 *  @param {Event} _event Event used by cast.receiver.games.GameManager.
 */
GameManagerListener.prototype.onGameMessageReceived = function(_event) {
    console.info("[gameManagerListener][onGameMessageReceived]");
    console.info(_event);
};

/* 
 *  Fired when the game manager receives a request that changes 
 *  gameplay state to cast.receiver.games.GameplayState.PAUSED. 
 * 
 *  @param {Event} _event Event used by cast.receiver.games.GameManager.
 */
GameManagerListener.prototype.onGamePaused = function(_event) {
    console.info("[gameManagerListener][onGamePaused]");
    console.info(_event);
};

/*
 *  Fired when the game manager receives a request that changes gameplay 
 *  state to cast.receiver.games.GameplayState.RUNNING. 
 *  
 *  @param {Event} _event Event used by cast.receiver.games.GameManager.
 */
GameManagerListener.prototype.onGameRunning = function(_event) {
    console.info("[gameManagerListener][onGameRunning]");
    console.info(_event);
};

/*
 *  Fired when the game manager receives a request that changes gameplay 
 *  state to cast.receiver.games.GameplayState.SHOWING_INFO_SCREEN.
 *  
 *  @param {Event} _event Event used by cast.receiver.games.GameManager.
 */
GameManagerListener.prototype.onGameShowingInfoScreen = function(_event) {
    console.info("[gameManagerListener][onGameShowingInfoScreen]");
    console.info(_event);
};

/*
 *  Fired when the game manager receives a request that changes game 
 *  status text.
 *  
 *  @param {Event} _event Event used by cast.receiver.games.GameManager.
 */
GameManagerListener.prototype.onGameStatusTextChanged = function(_event) {
    console.info("[gameManagerListener][onGameStatusTextChanged]");
    console.info(_event);
};

/*
 *  Fired when the game manager receives a request that changes lobby 
 *  state to cast.receiver.games.LobbyState.CLOSED.
 *  
 *  @param {Event} _event Event used by cast.receiver.games.GameManager.
 */
GameManagerListener.prototype.onLobbyClosed = function(_event) {
    console.info("[gameManagerListener][onLobbyClosed]");
    console.info(_event);
};

/*
 *  Fired when the game manager receives a request that changes lobby 
 *  state to cast.receiver.games.LobbyState.OPEN.
 *  
 *  @param {Event} _event Event used by cast.receiver.games.GameManager.
 */
GameManagerListener.prototype.onLobbyOpen = function(_event) {
    console.info("[gameManagerListener][onLobbyOpen]");
    console.info(_event);
};

/*
 *  Fired when the game manager receives a request that changes player 
 *  state to cast.receiver.games.PlayerState.AVAILABLE.
 *  
 *  @param {Event} _event Event used by cast.receiver.games.GameManager.
 */
GameManagerListener.prototype.onPlayerAvailable = function(_event) {
    console.info("[gameManagerListener][onPlayerAvailable]");
    console.info(_event);
};

/*
 *  Fired when the game manager receives a request that changes player data 
 *  (e.g. cast.receiver.games.GameManagerReceiverClient.sendPlayerDataRequest).
 *  
 *  @param {Event} _event Event used by cast.receiver.games.GameManager.
 */
GameManagerListener.prototype.onPlayerDataChanged = function(_event) {
    console.info("[gameManagerListener][onPlayerDataChanged]");
    console.info(_event);
};

/*
 *  Fired when the game manager receives a request that changes 
 *  player state to cast.receiver.games.PlayerState.DROPPED.
 *  
 *  @param {Event} _event Event used by cast.receiver.games.GameManager.
 */
GameManagerListener.prototype.onPlayerDropped = function(_event) {
    console.info("[gameManagerListener][onPlayerDropped]");
    console.info(_event);
};

/*
 *  Fired when the game manager receives a request that changes player 
 *  state to cast.receiver.games.PlayerState.IDLE.
 *  
 *  @param {Event} _event Event used by cast.receiver.games.GameManager.
 */
GameManagerListener.prototype.onPlayerIdle = function(_event) {
    console.info("[gameManagerListener][onPlayerIdle]");
    console.info(_event);
};

/* 
 *  Fired when the game manager receives a request that changes player 
 *  state to cast.receiver.games.PlayerState.PLAYING. 
 *  
 *  @param {Event} _event Event used by cast.receiver.games.GameManager.
 */
GameManagerListener.prototype.onPlayerPlaying = function(_event) {
    console.info("[gameManagerListener][onPlayerPlaying]");
    console.info(_event);
};

/*
 *  Fired when the game manager receives a request that changes player 
 *  state to cast.receiver.games.PlayerState.QUIT.
 * 
 *  @param {Event} _event Event used by cast.receiver.games.GameManager.
 */
GameManagerListener.prototype.onPlayerQuit = function(_event) {
    console.info("[gameManagerListener][onPlayerQuit]");
    console.info(_event);
};

/*
 *  Fired when the game manager receives a request that changes player 
 *  state to cast.receiver.games.PlayerState.READY.
 *  
 *  @param {Event} _event Event used by cast.receiver.games.GameManager.
 */
GameManagerListener.prototype.onPlayerReady = function(_event) {
    console.info("[gameManagerListener][onPlayerReady]");
    console.info(_event);
};

However if I write the next lines before adding the GameManagerListener, then it works.. any idea? Thanks.

this.gameManagerListener = new GameManagerListener();
this.gameManagerListener.gd = this.gameManagerListener.onPlayerAvailable;
this.gameManagerListener.nd = this.gameManagerListener.onPlayerReady;
this.gameManagerListener.kd = this.gameManagerListener.onPlayerIdle; 
...
wachino
  • 1
  • 2

1 Answers1

0

This should be fixed in Game manager 1.0.0.3. Please see this ticket on the Cast issue tracker.

not_a_bot
  • 2,332
  • 2
  • 19
  • 33