Skip to content

Instantly share code, notes, and snippets.

View JIntrocaso's full-sized avatar

Jamie Introcaso JIntrocaso

View GitHub Profile
@JIntrocaso
JIntrocaso / Consume.cs
Created January 25, 2022 02:46
Consume Method
View Consume.cs
consumer.Received += (model, ea) =>
{
var body = ea.Body.ToArray();
var message = Encoding.UTF8.GetString(body);
var notification = JsonSerializer.Deserialize<Notification>(message);
var senderName = notification?.Properties?.GetValueOrDefault("SenderName");
Console.WriteLine($"Received event: {notification?.Event} Sent by: {senderName}");
};
@JIntrocaso
JIntrocaso / Notification.cs
Created January 24, 2022 23:55
Message Classes
View Notification.cs
using System.Text.Json.Serialization;
namespace Receiver.Models
{
public class Notification
{
public Guid MessageId { get; set; }
public DateTime Timestamp { get; set; }
public string Sender { get; set; } = "None Sent";
public string Event { get; set; } = string.Empty;
@JIntrocaso
JIntrocaso / ipifyAPICalls.ts
Created September 24, 2020 23:45
IPIFY API Call
View ipifyAPICalls.ts
public getAPIEndpoint() {
this.httpClient.get("https://api.ipify.org?format=json").subscribe(response => {
console.log(response);
this.ipAddress = response["ip"];
});
}
public getGeoEndpoint() {
this.httpClient.get("https://geo.ipify.org/api/v1?apiKey=" + this.apiKey).subscribe(response => {
console.log(response);