Chats now only try to connect, if they are opened

This commit is contained in:
Patrick Hellebrand
2021-09-23 12:53:57 +02:00
committed by Felix Hartmann (PEA3-Fe-FI)
parent b12d3f3f4f
commit c00a7ff379
3 changed files with 20 additions and 7 deletions

View File

@@ -1,14 +1,17 @@
using SocketIOSharp.Server.Client;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Runtime.CompilerServices;
namespace PolyChat.Models
{
public class ChatPartner
public class ChatPartner : INotifyPropertyChanged
{
public string Name;
public string Code;
public ObservableCollection<ChatMessage> Messages;
private SocketIOSocket socketIOSocket;
public event PropertyChangedEventHandler PropertyChanged;
public ChatPartner(string name, string code, ObservableCollection<ChatMessage> messages = null)
{
@@ -20,6 +23,11 @@ namespace PolyChat.Models
public SocketIOSocket SocketIOSocket { get => socketIOSocket; set => socketIOSocket = value; }
private void NotifyPropertyChanged([CallerMemberName] string propertyName = "")
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
public void AddMessage(ChatMessage message)
{
Messages.Add(message);
@@ -28,6 +36,7 @@ namespace PolyChat.Models
public void SetName(string name)
{
Name = name;
NotifyPropertyChanged("Name");
}
}
}