Ejemplo n.º 1
0
 //static int counter = 0;
 //static bool alreadyCalled;
 //static string group;
 // Send message
 public void Send(string name, string message, string group, string date)
 {
     //Clients.All.addMessage(name, message);
     Clients.Caller.clearError();
     if (message.Length > 0)
     {
         if (group is null)
         {
             Clients.Caller.errorEmptyMessage(name, "First open chat");
             return;
         }
         Clients.Group(group).addMessage(name, message);
         //Clients.Group(group).addHeader(name);
         Clients.OthersInGroup(group).addHeader(name);
         Clients.OthersInGroup(group).playMusic();
         Clients.Others.showNotification(group, date, name);
         var y = new ConversationHistory
         {
             UserName = name, Message = message, UserGroup = group, ConnID = Context.ConnectionId, Date = date
         };
         x.ConversationHistory.Add(y);
         x.SaveChanges();
     }
     else
     {
         Clients.Caller.errorEmptyMessage(name, "The message can not be empty");
     }
 }
Ejemplo n.º 2
0
        public MainWindow()
        {
            InitializeComponent();
            var _client  = new Client();
            var _history = ConversationHistory.Load("history.json");
            ConnectionViewModel connectionViewModel = new ConnectionViewModel(_client);;
            var chatViewModel    = new ChatViewModel(_client, _history);
            var historyViewModel = new HistoryViewModel(_history);

            DataContext = new MainViewModel(connectionViewModel, chatViewModel, historyViewModel, _client);
        }