In part one of this article, I did an overview of the XNA Streaming project. In this part I’m going to describe the File Transfer Service.
The main responsibility of the File Transfer Service is to provide access to streamable games. The service stores the game files in a database table, together with their relative file paths. This way the file system structure can be recreated when downloading the game. The game’s name, author and a short description are also stored in another table.
The operations that the File Transfer Service supports are:
- Create a game with no files: This operation simply creates a game entity with the game’s name, author and description with no files.
- Upload a file for an already created game: This operation stores a file together with it’s relative path to the game’s folder for a previously created game. This operation gets invoked for each file in a game’s folder.
- Delete a game: Removes a game from the database together with its files.
- Get all uploaded games: This operation returns a collection of general information about uploaded games (game name, uploader and description).
- Get all relative file paths for a game: This operation returns a collection containing the relative paths for all the files of a game. This list can be used to download each file and save locally.
- Download a file from a game: This operation downloads a file specified by the game to which it belongs and its relative path to the game folder.
- Get start up information for a game: This operation returns the game’s name, which is used to identify the streamed game at runtime, the address and endpoint name for the Streaming service. This information is used to start a game, both in observe or in broadcast mode.
The download/upload of each file takes place through streaming. This limits the in memory portion of a potentially large file at any moment to the size of the buffer of the stream. Stream parameters and return values are a feature of WCF services.
The File Streaming Service has as UI an XBAP that helps in uploading, downloading and starting a game.