cast receiver GameManager 添加 GameManagerListener 错误

Posted

技术标签:

【中文标题】cast receiver GameManager 添加 GameManagerListener 错误【英文标题】:cast receiver GameManager add GameManagerListener Error 【发布时间】:2015-08-04 16:30:26 【问题描述】:

我正在尝试实现 GameManagerInterface 并将其添加到 GameManager 但我总是收到下一个错误:

未捕获的错误: player_available event.cast.receiver.games.j.hk @ cast_games_receiver.js:249 缺少监听器方法

这是我的代码:

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);
;

但是,如果我在添加 GameManagerListener 之前编写下一行,那么它可以工作.. 有什么想法吗?谢谢。

this.gameManagerListener = new GameManagerListener();
this.gameManagerListener.gd = this.gameManagerListener.onPlayerAvailable;
this.gameManagerListener.nd = this.gameManagerListener.onPlayerReady;
this.gameManagerListener.kd = this.gameManagerListener.onPlayerIdle; 
...

【问题讨论】:

【参考方案1】:

这应该在游戏管理器 1.0.0.3 中修复。请在 Cast 问题跟踪器上查看 this 票证。

【讨论】:

以上是关于cast receiver GameManager 添加 GameManagerListener 错误的主要内容,如果未能解决你的问题,请参考以下文章

迁移到新版本 Cast Receiver 的最佳方式

Cast Styled Media Receiver 图像资产(背景、徽标等)的尺寸指南?

关闭编译 Google Cast Javascript 接收器应用程序

如何在 google cast(前贴片广告、插播广告)中加入广告(广告)

Chrome 浏览器 Cast 扩展取代了 Cactool Cast 按钮

Google Cast 频道错误