using System; using System.Diagnostics; using System.Text.Json; namespace PolyChat.Models { public class ChatMessage { public string Origin; public string Type; public string Content; public DateTime TimeStamp; public readonly bool Foreign; public ChatMessage() { } /// /// Create own Message (directly sent) /// /// My IP /// Message Type /// Message Content (not JSON) public ChatMessage(string origin, string type, string content) { Origin = origin; TimeStamp = DateTime.Now; Type = type; Content = content; // TODO Foreign = false; Debug.WriteLine("Created Message: " + ToString()); } /// /// Create Message loaded with timestamp /// /// Origin IP /// Message Type /// Message Content (not JSON) /// Message Content (not JSON) public ChatMessage(string origin, string type, string content, DateTime timeStamp, bool foreign = false) { Origin = origin; TimeStamp = timeStamp; Type = type; Content = content; Foreign = foreign; Debug.WriteLine("Created Loaded Message: " + ToString()); } override public string ToString() { string prefix = Foreign ? "Other" : "Me"; return $"{Type} from {prefix}: {Content}({Origin})"; } } }