Ejemplo n.º 1
0
        static async Task Connect(Client.Client client, ISettings settings)
        {
            Logger.WriteLine("Name: ", ConsoleColor.Red);
            var name = Console.ReadLine();

            await client.ConnectAsync(name, settings);
        }
Ejemplo n.º 2
0
        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;
        }