diff --git a/iOS/AppDelegate.cs b/iOS/AppDelegate.cs index 0ea4184..ba04aad 100644 --- a/iOS/AppDelegate.cs +++ b/iOS/AppDelegate.cs @@ -10,7 +10,7 @@ namespace qController.iOS public override bool FinishedLaunching(UIApplication app, NSDictionary options) { global::Xamarin.Forms.Forms.Init(); - Log.Logger = new LoggerConfiguration().WriteTo.NSLog().MinimumLevel.Debug().CreateLogger(); + Log.Logger = new LoggerConfiguration().WriteTo.NSLog().MinimumLevel.Error().CreateLogger(); LoadApplication(new App()); diff --git a/qController.Standard/Classes/Cell/QInstanceCell.cs b/qController.Standard/Classes/Cell/QInstanceCell.cs index cb12400..dfe3f80 100644 --- a/qController.Standard/Classes/Cell/QInstanceCell.cs +++ b/qController.Standard/Classes/Cell/QInstanceCell.cs @@ -110,7 +110,7 @@ namespace qController.Cell void Connect(object sender, EventArgs e) { - App.NavigationPage.Navigation.PushAsync(new ControlPage(nameLabel.Text,addressLabel.Text)); + App.rootPage.Detail.Navigation.PushAsync(new ControlPage(nameLabel.Text, addressLabel.Text)); Log.Debug("QINSTANCECELL - Connect To " + nameLabel.Text + " Pressed"); } } diff --git a/qController.Standard/Classes/Communication/SharpOSC/TCPClient.cs b/qController.Standard/Classes/Communication/SharpOSC/TCPClient.cs index c1ed4af..b0176b7 100644 --- a/qController.Standard/Classes/Communication/SharpOSC/TCPClient.cs +++ b/qController.Standard/Classes/Communication/SharpOSC/TCPClient.cs @@ -31,7 +31,7 @@ namespace SharpOSC } public delegate void MessageReceivedHandler(object source, MessageEventArgs args); public event MessageReceivedHandler MessageReceived; - + private Thread receivingThread; string _address; TcpClient client; @@ -49,17 +49,20 @@ namespace SharpOSC public bool Connect() { - client = new TcpClient(); - - if (!client.ConnectAsync(Address, Port).Wait(TimeSpan.FromSeconds(1))) + try { + client = new TcpClient(Address, Port); + receivingThread = new Thread(ReceiveLoop); + receivingThread.Start(); + Log.Debug($"[tcpclient] connected to <{Address}:{Port}>"); + return true; + } + catch (Exception e) + { + Log.Error(e.Message); return false; } - Thread receivingThread = new Thread(ReceiveLoop); - receivingThread.Start(); - return true; - } public void Send(byte[] message) @@ -96,9 +99,9 @@ namespace SharpOSC { Random random = new Random(); int num = random.Next(1000); - NetworkStream netStream = client.GetStream(); try { + NetworkStream netStream = client.GetStream(); netStream.ReadTimeout = 250; List responseData = new List(); if (netStream.CanRead) @@ -125,7 +128,7 @@ namespace SharpOSC } } catch(Exception e) { - Log.Debug("TCPClient - Receive Exception: " + e.ToString()); + //Log.Debug("TCPClient - Receive Exception: " + e.ToString()); } } @@ -159,12 +162,15 @@ namespace SharpOSC public void Close() { - if (client.Connected) + if (client != null) { - client.GetStream().Close(); - client.Close(); + if (client.Connected) + { + Log.Debug($"[tcpClient] closing connection to {Address}"); + client.GetStream().Close(); + client.Close(); + } } - } protected virtual void OnMessageReceived(OscMessage msg)