/// <summary> /// Creates a MixPlay game. /// </summary> /// <param name="connection">The Mixer connection to use</param> /// <param name="channel">The owning channel</param> /// <param name="user">The owning user</param> /// <param name="gameName">The name of the game</param> /// <param name="initialScene">The initial scene</param> /// <returns>The created MixPlay game</returns> public static async Task <MixPlayGameListingModel> CreateMixPlay2Game(MixerConnection connection, ChannelModel channel, UserModel user, string gameName, MixPlaySceneModel initialScene) { MixPlayGameModel game = new MixPlayGameModel() { name = gameName, ownerId = user.id, }; game = await connection.MixPlay.CreateMixPlayGame(game); game.controlVersion = "2.0"; game = await connection.MixPlay.UpdateMixPlayGame(game); IEnumerable <MixPlayGameListingModel> gameListings = await connection.MixPlay.GetOwnedMixPlayGames(channel); MixPlayGameListingModel gameListing = gameListings.FirstOrDefault(gl => gl.id.Equals(game.id)); MixPlayGameVersionModel version = gameListing.versions.First(); version.controls.scenes.Add(initialScene); version.controlVersion = "2.0"; version = await connection.MixPlay.UpdateMixPlayGameVersion(version); gameListings = await connection.MixPlay.GetOwnedMixPlayGames(channel); gameListing = gameListings.FirstOrDefault(gl => gl.id.Equals(game.id)); return(gameListing); }
public static async Task<MixPlayGameListingModel> CreateTestGame(MixerConnection connection, ChannelModel channel) { UserModel user = await UsersServiceUnitTests.GetCurrentUser(connection); IEnumerable<MixPlayGameListingModel> gameListings = await connection.MixPlay.GetOwnedMixPlayGames(channel); MixPlayGameListingModel previousTestGame = gameListings.FirstOrDefault(g => g.name.Equals(MixPlayServiceUnitTests.GameName)); if (previousTestGame != null) { await MixPlayServiceUnitTests.DeleteTestGame(connection, previousTestGame); } MixPlayGameModel game = new MixPlayGameModel() { name = MixPlayServiceUnitTests.GameName, ownerId = user.id, }; game = await connection.MixPlay.CreateMixPlayGame(game); Assert.IsNotNull(game); Assert.IsTrue(game.id > 0); game.controlVersion = "2.0"; game = await connection.MixPlay.UpdateMixPlayGame(game); Assert.IsNotNull(game); Assert.IsTrue(game.id > 0); gameListings = await connection.MixPlay.GetOwnedMixPlayGames(channel); Assert.IsNotNull(gameListings); Assert.IsTrue(gameListings.Count() > 0); MixPlayGameListingModel gameListing = gameListings.FirstOrDefault(gl => gl.id.Equals(game.id)); Assert.IsNotNull(gameListing); MixPlayGameVersionModel version = gameListing.versions.First(); MixPlaySceneModel defaultScene = new MixPlaySceneModel() { sceneID = "default", }; defaultScene.buttons.Add(MixPlayClientUnitTests.CreateTestButton()); defaultScene.joysticks.Add(MixPlayClientUnitTests.CreateTestJoystick()); version.controls.scenes.Add(defaultScene); version.controlVersion = "2.0"; version = await connection.MixPlay.UpdateMixPlayGameVersion(version); gameListings = await connection.MixPlay.GetOwnedMixPlayGames(channel); Assert.IsNotNull(gameListings); Assert.IsTrue(gameListings.Count() > 0); gameListing = gameListings.FirstOrDefault(gl => gl.id.Equals(game.id)); Assert.IsNotNull(gameListing); return gameListing; }
/// <summary> /// Updates the specified MixPlay game version. /// </summary> /// <param name="version">The MixPlay game version to update</param> /// <returns>The updated MixPlay game version</returns> public async Task <MixPlayGameVersionModel> UpdateMixPlayGameVersion(MixPlayGameVersionModel version) { Validator.ValidateVariable(version, "version"); // Need to strip out all of the non-updateable fields in order for the API to not return a 403 error MixPlayGameVersionUpdateableModel updateableVersion = JSONSerializerHelper.Clone <MixPlayGameVersionUpdateableModel>(version); updateableVersion.controls = version.controls; return(await this.PutAsync <MixPlayGameVersionModel>("interactive/versions/" + version.id, this.CreateContentFromObject(updateableVersion))); }
public void GetMixPlayVersion() { TestWrapper(async (MixerConnection connection) => { ChannelModel channel = await ChannelsServiceUnitTests.GetChannel(connection); IEnumerable<MixPlayGameListingModel> games = await connection.MixPlay.GetOwnedMixPlayGames(channel); Assert.IsNotNull(games); Assert.IsTrue(games.Count() > 0); MixPlayGameVersionModel version = await connection.MixPlay.GetMixPlayGameVersion(games.First().versions.First()); Assert.IsNotNull(version); }); }
private MixPlayClient(ChannelModel channel, MixPlayGameModel game, MixPlayGameVersionModel version, string shareCode, OAuthTokenModel authToken, IEnumerable <string> connections) { Validator.ValidateVariable(channel, "channel"); Validator.ValidateVariable(game, "game"); Validator.ValidateVariable(version, "version"); Validator.ValidateVariable(authToken, "authToken"); Validator.ValidateList(connections, "connections"); this.Channel = channel; this.Game = game; this.Version = version; this.ShareCode = shareCode; this.connections = connections; this.oauthAccessToken = authToken.accessToken; }
/// <summary> /// Deletes the specified MixPlay game version. /// </summary> /// <param name="version">The MixPlay game version to delete</param> /// <returns>Whether the operation succeeded</returns> public async Task <bool> DeleteMixPlayGameVersion(MixPlayGameVersionModel version) { Validator.ValidateVariable(version, "version"); return(await this.DeleteAsync("interactive/versions/" + version.id)); }
/// <summary> /// Gets the specified MixPlay game version. /// </summary> /// <param name="version">The MixPlay game version to get</param> /// <returns>The MixPlay game version</returns> public async Task <MixPlayGameVersionModel> GetMixPlayGameVersion(MixPlayGameVersionModel version) { Validator.ValidateVariable(version, "version"); return(await this.GetMixPlayGameVersion(version.id)); }
/// <summary> /// Creates the specified MixPlay game version. /// </summary> /// <param name="version">The MixPlay game version to create</param> /// <returns>The created MixPlay game version</returns> public async Task <MixPlayGameVersionModel> CreateMixPlayGameVersion(MixPlayGameVersionModel version) { Validator.ValidateVariable(version, "version"); return(await this.PostAsync <MixPlayGameVersionModel>("interactive/versions", this.CreateContentFromObject(version))); }
/// <summary> /// Creates an MixPlay client using the specified connection to the specified channel and game. /// </summary> /// <param name="connection">The connection to use</param> /// <param name="channel">The channel to connect to</param> /// <param name="game">The game to use</param> /// <param name="version">The version of the game to use</param> /// <param name="shareCode">The share code used to connect to a game shared with you</param> /// <returns>The MixPlay client for the specified channel and game</returns> public static async Task <MixPlayClient> CreateFromChannel(MixerConnection connection, ChannelModel channel, MixPlayGameModel game, MixPlayGameVersionModel version, string shareCode) { Validator.ValidateVariable(connection, "connection"); Validator.ValidateVariable(channel, "channel"); Validator.ValidateVariable(game, "game"); Validator.ValidateVariable(version, "version"); OAuthTokenModel authToken = await connection.GetOAuthToken(); IEnumerable <string> connections = await connection.MixPlay.GetMixPlayHosts(); return(new MixPlayClient(channel, game, version, shareCode, authToken, connections)); }
/// <summary> /// Creates an MixPlay client using the specified connection to the specified channel and game. /// </summary> /// <param name="connection">The connection to use</param> /// <param name="channel">The channel to connect to</param> /// <param name="game">The game to use</param> /// <param name="version">The version of the game to use</param> /// <returns>The MixPlay client for the specified channel and game</returns> public static async Task <MixPlayClient> CreateFromChannel(MixerConnection connection, ChannelModel channel, MixPlayGameModel game, MixPlayGameVersionModel version) { Validator.ValidateVariable(connection, "connection"); Validator.ValidateVariable(channel, "channel"); Validator.ValidateVariable(game, "game"); Validator.ValidateVariable(version, "version"); return(await MixPlayClient.CreateFromChannel(connection, channel, game, version, null)); }