public Screenshot(Game game, HydraInt64 profileId, HydraHashMap metadata, HydraBinary imageData) { byte[] random = new byte[8]; using (var rng = System.Security.Cryptography.RandomNumberGenerator.Create()) { rng.GetBytes(random); } long newGuid = BitConverter.ToInt64(random, 0); Data = new HydraHashMap(new Dictionary <string, IHydraItem>() { { "emu", new HydraBool(true) }, { "rating", new HydraInt32(0) }, { "tags", new HydraArray() }, { "url", new HydraUtf8String("") }, { "created_at", new HydraDateTime(DateTime.Now) }, { "rating_history", new HydraHashMap(new Dictionary <string, IHydraItem>() { { "monthly", new HydraHashMap(new Dictionary <string, IHydraItem>() { { "count", new HydraInt32(0) }, { "sum", new HydraInt32(0) }, { "average", new HydraInt32(0) }, }) }, { "daily", new HydraHashMap(new Dictionary <string, IHydraItem>() { { "count", new HydraInt32(0) }, { "sum", new HydraInt32(0) }, { "average", new HydraInt32(0) }, }) }, { "weekly", new HydraHashMap(new Dictionary <string, IHydraItem>() { { "count", new HydraInt32(0) }, { "sum", new HydraInt32(0) }, { "average", new HydraInt32(0) }, }) } }) }, { "meta_data", metadata }, { "guid", new HydraInt64(newGuid) }, { "owner_guid", new HydraInt64(1) }, { "size", new HydraInt32(imageData.Value.Length) } }); ImageData = imageData.Value; }
public Character(Game game, HydraInt64 profileId, HydraHashMap metadata, HydraBinary imageData) { metadata.Items["Avatar Version"] = new HydraUtf8String(((HydraInt32)metadata.Items["Avatar Version"]).Value.ToString()); Data = new HydraHashMap(new Dictionary <string, IHydraItem>() { { "emu", new HydraBool(true) }, { "rating", new HydraInt32(0) }, { "tags", new HydraArray() }, { "url", new HydraUtf8String("") }, { "created_at", new HydraDateTime(DateTime.Now) }, { "rating_history", new HydraHashMap(new Dictionary <string, IHydraItem>() { { "monthly", new HydraHashMap(new Dictionary <string, IHydraItem>() { { "count", new HydraInt32(0) }, { "sum", new HydraInt32(0) }, { "average", new HydraInt32(0) }, }) }, { "daily", new HydraHashMap(new Dictionary <string, IHydraItem>() { { "count", new HydraInt32(0) }, { "sum", new HydraInt32(0) }, { "average", new HydraInt32(0) }, }) }, { "weekly", new HydraHashMap(new Dictionary <string, IHydraItem>() { { "count", new HydraInt32(0) }, { "sum", new HydraInt32(0) }, { "average", new HydraInt32(0) }, }) } }) }, { "queue_count", new HydraInt32(0) }, { "meta_data", metadata }, { "guid", GenerateGuid() }, { "owner_guid", new HydraInt64(1) }, { "size", new HydraInt32(imageData.Value.Length) } }); ImageData = imageData.Value; }
private void Create(HydraRequest request) { List <IHydraItem> items = HydraItemDeserializer.DeserializeAll(request.PostData); HydraInt64 profileId = items[0] as HydraInt64; HydraHashMap map = items[1] as HydraHashMap; HydraBinary imageBinary = items[2] as HydraBinary; Game game = Game.GetFromApiKey(request.ApiKey); string category = ((HydraUtf8String)map.Items["category"]).Value; if (category == "characters") { Character character = new Character(game, profileId, map, imageBinary); character.Save(); Console.WriteLine("Saved new character. ID {0}", character.ID); HydraResponse response = new HydraResponse(Connection, new HydraInt64(character.ID)); response.Send(); } else if (category == "screenshots") { Screenshot screenshot = new Screenshot(game, profileId, map, imageBinary); screenshot.Save(); Console.WriteLine("Saved new screenshot. ID {0}", screenshot.ID); HydraResponse response = new HydraResponse(Connection, new HydraInt64(screenshot.ID)); response.Send(); } else { throw new Exception("Unknown category? " + category); } }