using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
using Microsoft.AspNet.SignalR.Client.Hubs;

namespace SignalRClient
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("[ENTER]: Starten");
            Console.ReadLine();

            ConnectToSignalR().Wait();
        }

        private static async Task ConnectToSignalR()
        {
            var hubConnection = new HubConnection("http://localhost:8081/");
            IHubProxy proxy = hubConnection.CreateHubProxy("ChatHub");
            proxy.On<String>("Receive", msg => Console.WriteLine("  > Received: " +  msg));

            await hubConnection.Start();
            Console.WriteLine("Gestartet ...\n");
            string line;
            while ((line = Console.ReadLine()) != "exit")
            {
                await proxy.Invoke("Send", line);
            }
        }
    }
}
