private void EditMessageProperties(INetherMessage gameEvent) { var props = gameEvent.GetType().GetProperties(); foreach (var prop in props) { var propName = prop.Name; if (propName != "ClientUtcTime" && Program.PropertyCache.ContainsKey(propName)) { prop.SetValue(gameEvent, Program.PropertyCache[propName]); } var propValue = prop.GetValue(gameEvent); if (propName == "Type" || propName == "Version") { // Don't ask for input for these properties, just display their // values since they are static and can't be changed Console.WriteLine($"{propName}: {propValue}"); } else { var propertyType = prop.PropertyType; var o = EditProperty(propName, propValue, propertyType); prop.SetValue(gameEvent, o); Program.PropertyCache[propName] = o; } } }
public async Task SendMessageAsync(INetherMessage msg, DateTime?dbgEnqueuedTimeUtc = default(DateTime?)) { Console.Write("|"); // Serialize object to JSON var json = JsonConvert.SerializeObject( msg, Formatting.Indented, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); if (dbgEnqueuedTimeUtc.HasValue) { var o = JObject.Parse(json); o.Add("dbgEnqueuedTimeUtc", dbgEnqueuedTimeUtc); json = o.ToString(); } var data = new EventData(Encoding.UTF8.GetBytes(json)); _queue.Enqueue(data); if (_queue.Count >= MessageBatchSize) { await SendMessagesInQueueAsync(); } }
private static void SendMessage(INetherMessage gameEvent) { // Serialize object to JSON var msg = JsonConvert.SerializeObject( gameEvent, Formatting.Indented, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); EventHubManager.SendMessageToEventHub(msg).Wait(); }
public async Task SendGameEventAsync(INetherMessage gameEvent) { // Retrieve information of where to send analytics data //TODO: Cache data so we don't ask everytime await GetAnalyticsEndpointInformation(); // Setup client to call Event Hub var httpClient = new HttpClient(); httpClient.DefaultRequestHeaders.Authorization = AuthenticationHeaderValue.Parse(_authorization); // Create content to send var content = new StringContent( JsonConvert.SerializeObject(gameEvent), Encoding.UTF8, "application/json"); //TODO: Implement retry logic and handling of exceptions await httpClient.PostAsync(_eventHubUrl, content); }
public async Task SendMessageAsync(INetherMessage msg, DateTime?dbgEnqueuedTimeUtc = null) { Console.Write("|"); // Serialize object to JSON var json = JsonConvert.SerializeObject( msg, Formatting.Indented, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); if (dbgEnqueuedTimeUtc.HasValue) { var o = JObject.Parse(json); o.Add("dbgEnqueuedTimeUtc", dbgEnqueuedTimeUtc); json = o.ToString(); } await _client.SendAsync(new EventData(Encoding.UTF8.GetBytes(json))); }
private void TypedMessageSelected(INetherMessage gameEvent) { EditMessageProperties(gameEvent); SendMessage(gameEvent); }
public Task SendMessageAsync(INetherMessage msg, DateTime?dbgEnqueuedTimeUtc = null) { Console.Write("_"); return(Task.CompletedTask); }
public async Task SendGameEventAsync(INetherMessage gameEvent) { var json = JsonConvert.SerializeObject(gameEvent); var eventData = new EventData(Encoding.UTF8.GetBytes(json)); await _eventHubClient.SendAsync(eventData); }
public Task SendGameEventAsync(INetherMessage gameEvent) { return(Task.CompletedTask); }
private void StaticGameEventSelected(INetherMessage gameEvent) { EditGameEventProperties(gameEvent); SendGameEvent(gameEvent); }