private void InitializeEvents() { _eventAggregator.GetEvent <ConnectToServerEvent>().Subscribe(async payload => { _settings.Uri = payload.Host; await _client.ConnectAsync(payload.Name, _settings); }); _eventAggregator.GetEvent <SendMessageTextEvent>().Subscribe(async text => { if (_currentToUser != null) { _eventAggregator.GetEvent <MessageSentEvent>().Publish(new Message { From = _client.Me.User, To = _currentToUser, Text = text }); await _client.SendMessageAsync(text, _currentToUser); } }); _eventAggregator.GetEvent <SelectUserEvent>().Subscribe(u => _currentToUser = u); _client.ConnectedToServer += ClientOnConnectedToServer; _client.MessageReceived += ClientOnMessageReceived; _client.UserConnected += ClientOnUserConnected; _client.UserDisconnected += ClientOnUserDisconnected; }