WP7 游戏:停用时调用 Web 服务(逻辑删除)
我遇到了一个奇怪的问题,我想知道这是否正常或者我是否遗漏了某些东西。
情况如下:
- 我正在 XNA 中为 WP7 开发多人游戏
- 当用户退出游戏(进入墓碑或退出)时,我想警告其他玩家,玩家离开了,
- 我重写了 Game.OnExiting() 方法来调用我的Web服务,并且我在这一行上放置了一个断点
- 每次,断点被命中,调用,没有发生错误,但服务器从未收到调用调用
是否正常由于游戏正在退出而未在服务器上进行处理?
这是代码:
protected override void OnExiting(object sender, EventArgs args)
{
if (GameManager.Instance.IsOnlineGame && !Guide.IsVisible)
{
GameManager.Instance.Multiplayer.QuitGame();
}
base.OnExiting(sender, args);
}
internal void QuitGame()
{
_client.QuitGameAsync(GameManager.Instance.GameId, _myRank);
}
I'm running into a weird problem and I want to know if it is normal or if I'm missing something.
Here's the situation :
- I'm developping a multiplayer game in XNA for WP7
- When a user quits the game (enters in tombstoning or exiting), I want to warn others players that a player left
- I override the
Game.OnExiting()
method to call my Web Service, and I have put a breakpoint on this line - Each time, the breakpoint gets hit, the call is made, no error occurs, but the server never receives the call
Is it normal that the call is not processed on the server because the game is exiting?
Here's the code :
protected override void OnExiting(object sender, EventArgs args)
{
if (GameManager.Instance.IsOnlineGame && !Guide.IsVisible)
{
GameManager.Instance.Multiplayer.QuitGame();
}
base.OnExiting(sender, args);
}
internal void QuitGame()
{
_client.QuitGameAsync(GameManager.Instance.GameId, _myRank);
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您的应用程序在退出时只有很短的时间来执行任何操作。调用网络服务可能需要比您允许的时间更长的时间。
从您发布的代码量来看,也不清楚哪些资源可用于进行调用(并传递必要的数据)。
如果您这样做,则不应依赖发送到服务器的消息。这可能会对您的应用程序逻辑产生影响。
Your app only has a very short time to perform any operations when exiting. Calling a web service has the potential to take longer than may be permitted to you.
It's not clear from the amount of code you have posted what resources are available to make the call (and pass necessary data) either.
If you do do this you shouldn't rely on that message being sent to the server. This may have implications for your applicaiton logic.
科学解释:
致谢:dadoo Games http://forums.create.msdn.com/forums/ t/79737.aspx
Scientific explanations:
Credits : dadoo Games on http://forums.create.msdn.com/forums/t/79737.aspx