Example #1
0
        private void OnFileChangedHandler(object sender, FileSystemEventArgs e)
        {
            if (e.Name != _filename)
            {
                return;
            }
            string newLine = FileHelper.ReadLastLine(_path, _encoding);
            var    message = MessageDataEntity.Parse(newLine);

            switch (message.Text)
            {
            case "Logon":
                OnUserStatusChanged?.Invoke(new OnUserStatusChangedArgs(message.UserName, true, message.DateTime));
                break;

            case "Logout":
                OnUserStatusChanged?.Invoke(new OnUserStatusChangedArgs(message.UserName, false, message.DateTime));
                break;

            default:
                OnMessageReceived?.Invoke(new OnMessageReceivedArgs(new MessageData(
                                                                        message.Id,
                                                                        message.DateTime,
                                                                        message.UserName,
                                                                        message.Text,
                                                                        message.UserName == CurrentUserContext.CurrentUserName,
                                                                        message.ReplyToMessageId)));
                break;
            }
        }
Example #2
0
 public void UserLoggedOut(User user)
 {
     OnUserStatusChanged?.Invoke(this, new OnUserStatusChangesEventArgs {
         User = user, IsOnline = false
     });
 }