using Xamarin.Forms;
using Xamarin.Forms.Xaml;

namespace OrderStacks.view
{
    [XamlCompilation(XamlCompilationOptions.Compile)]
    public partial class Testconnectivité : ContentPage
    {

        //HubConnection connection;
        public Testconnectivité()
        {
            /*InitializeComponent();
            NavigationPage.SetHasNavigationBar(this, false);

            connection = new HubConnectionBuilder().WithUrl("http://serverpm.herokuapp.com/").WithAutomaticReconnect().Build();
            connection.Closed += async (error) =>
            {
                await Task.Delay(new Random().Next(0, 5) * 1000);
                await connection.StartAsync();
            };*/

        }

        /*private async void Button_Clicked(object sender, EventArgs e)
        {
            connection.On<string, string>("Receive message", (user, message) =>
            {
                this.Dispatcher.BeginInvokeOnMainThread(() =>
                {
                    var newMessage = $"{user}: {message}";
                    messagesList.Items.Add(newMessage);
                });
            });

            try
            {
                await connection.StartAsync();
                messagesList.Items.Add("Connection started");
                connectButton.IsEnabled = false;
                sendButton.IsEnabled = true;
            }
            catch (Exception ex)
            {
                messagesList.Items.Add(ex.Message);
            }
        }

        private async void sendButton_Click(object sender, EventArgs e)
        {
            try
            {
                await connection.InvokeAsync("SendMessage",
                    userTextBox.Text, messageTextBox.Text);
            }
            catch (Exception ex)
            {
                messagesList.Items.Add(ex.Message);
            }
        }*/
    }
}