2

ネットワーク化されたXNAWP7ゲームでは、ゲームが非アクティブ化されたとき、たとえばゲーム中に検索ボタンを押したときにサーバーに通知したいと思います。ゲームはネットワーキングにHTTPリクエストを使用しており、HttpWebRequestsはすぐには処理されないようですが、UIスレッドのメインループのある時点で処理されます。つまり、アプリがトゥームストーンされる直前に非アクティブ化されたイベントハンドラーから作成したHttpWebRequestは、処理されません。

ソケットを使用してネットワークコード全体を書き直すことなく、これを回避する方法はありますか、それとも何かを誤解しただけですか?

4

1 に答える 1

2

The deactivated event is intended to be used to store application state as the application is deactivated (and possibly tombstoned). This event was never intended to be used to make web requests. Note that if you do try and make a request in this event, just because a response isn't received by the app doesn't mean that it doesn't get to the server though.

In that it's a networked game I'm assuming that you need to be online to play. If that's the case what happens if the device loses a network connection? Surely you'd be in just the same situation but you certainly couldn't send a notification to the server.
I suspect you need to think about your application model differently.

If you really need to be online to play could you not have the server just assume that the connection is lost if it doesn't hear from a device for a ertain period of time

Depending on the game you may also need to consider caching any game state/actions if the connection drops only briefly.

于 2011-08-16T21:03:17.423 に答える