Loading...

Listening for new GameStates

36 views

Loading...

Loading...

Transcript

The interactive transcript could not be loaded.

Loading...

Rating is available when the video has been rented.
This feature is not available right now. Please try again later.
Published on Mar 4, 2019

See: https://github.com/xaya/xaya_tutorial...

We must listen for updates in a thread. There are 4 important lines of code.

In our listener, we use the wrapper to get game states. The first thing to do is to tell the wrapper to wait until there's a new game state.

wrapper.xayaGameService.WaitForChange();

Once there's a game state, the thread resumes and we get the game state.

BitcoinLib.Responses.GameStateResult actualState =
wrapper.xayaGameService.GetCurrentState();

We then cast that as a `GameState` by deserialising the JSON.

state = JsonConvert.DeserializeObject-GameState-(actualState.gamestate);

The final step in our listening thread is to send the game state to the main UI thread.

sendingWorker.ReportProgress(0, state);

Loading...


to add this to Watch Later

Add to

Loading playlists...