mirror of
https://github.com/jwetzell/qController.git
synced 2026-08-20 14:39:12 +00:00
* AppDelegate.cs: Change Log Level
* QInstanceCell.cs: Update navigation * TCPClient.cs: Minor network stuff
This commit is contained in:
+1
-1
@@ -10,7 +10,7 @@ namespace qController.iOS
|
|||||||
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
|
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
|
||||||
{
|
{
|
||||||
global::Xamarin.Forms.Forms.Init();
|
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());
|
LoadApplication(new App());
|
||||||
|
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ namespace qController.Cell
|
|||||||
|
|
||||||
void Connect(object sender, EventArgs e)
|
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");
|
Log.Debug("QINSTANCECELL - Connect To " + nameLabel.Text + " Pressed");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ namespace SharpOSC
|
|||||||
}
|
}
|
||||||
public delegate void MessageReceivedHandler(object source, MessageEventArgs args);
|
public delegate void MessageReceivedHandler(object source, MessageEventArgs args);
|
||||||
public event MessageReceivedHandler MessageReceived;
|
public event MessageReceivedHandler MessageReceived;
|
||||||
|
private Thread receivingThread;
|
||||||
string _address;
|
string _address;
|
||||||
TcpClient client;
|
TcpClient client;
|
||||||
|
|
||||||
@@ -49,17 +49,20 @@ namespace SharpOSC
|
|||||||
|
|
||||||
public bool Connect()
|
public bool Connect()
|
||||||
{
|
{
|
||||||
client = new TcpClient();
|
try
|
||||||
|
|
||||||
if (!client.ConnectAsync(Address, Port).Wait(TimeSpan.FromSeconds(1)))
|
|
||||||
{
|
{
|
||||||
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Thread receivingThread = new Thread(ReceiveLoop);
|
|
||||||
receivingThread.Start();
|
|
||||||
return true;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Send(byte[] message)
|
public void Send(byte[] message)
|
||||||
@@ -96,9 +99,9 @@ namespace SharpOSC
|
|||||||
{
|
{
|
||||||
Random random = new Random();
|
Random random = new Random();
|
||||||
int num = random.Next(1000);
|
int num = random.Next(1000);
|
||||||
NetworkStream netStream = client.GetStream();
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
NetworkStream netStream = client.GetStream();
|
||||||
netStream.ReadTimeout = 250;
|
netStream.ReadTimeout = 250;
|
||||||
List<byte> responseData = new List<byte>();
|
List<byte> responseData = new List<byte>();
|
||||||
if (netStream.CanRead)
|
if (netStream.CanRead)
|
||||||
@@ -125,7 +128,7 @@ namespace SharpOSC
|
|||||||
}
|
}
|
||||||
} catch(Exception e)
|
} 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()
|
public void Close()
|
||||||
{
|
{
|
||||||
if (client.Connected)
|
if (client != null)
|
||||||
{
|
{
|
||||||
client.GetStream().Close();
|
if (client.Connected)
|
||||||
client.Close();
|
{
|
||||||
|
Log.Debug($"[tcpClient] closing connection to {Address}");
|
||||||
|
client.GetStream().Close();
|
||||||
|
client.Close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void OnMessageReceived(OscMessage msg)
|
protected virtual void OnMessageReceived(OscMessage msg)
|
||||||
|
|||||||
Reference in New Issue
Block a user