mirror of
https://github.com/jwetzell/QControlKit.git
synced 2026-08-21 15:09:09 +00:00
* QBrowser.cs: Change log levels
* QClient.cs: Change to Queue for TCP sending messages * QControlKit.csproj: * Info.plist: * MainPage.xaml.cs: * QControlKitXamDemo.csproj: * QControlKitXamDemo.iOS.csproj: * QControlKitXamDemo.Android.csproj: Updates * TCPClient.cs: Start work on send queue for TCP
This commit is contained in:
@@ -26,13 +26,17 @@ namespace QControlKit
|
|||||||
|
|
||||||
public async void ProbeForQLabInstances()
|
public async void ProbeForQLabInstances()
|
||||||
{
|
{
|
||||||
|
Log.Debug("[qbrowser] probing for instances");
|
||||||
|
|
||||||
IReadOnlyList<IZeroconfHost> results = await
|
IReadOnlyList<IZeroconfHost> results = await
|
||||||
ZeroconfResolver.ResolveAsync(QBonjour.TCPService,TimeSpan.FromSeconds(3));
|
ZeroconfResolver.ResolveAsync(QBonjour.TCPService,TimeSpan.FromSeconds(3));
|
||||||
|
|
||||||
foreach (var zeroconfHost in results)
|
foreach (var zeroconfHost in results)
|
||||||
{
|
{
|
||||||
|
Log.Debug($"[qbrowser] found host {zeroconfHost.IPAddress}:{zeroconfHost.DisplayName}");
|
||||||
foreach (var service in zeroconfHost.Services)
|
foreach (var service in zeroconfHost.Services)
|
||||||
{
|
{
|
||||||
|
Log.Debug($"[qbrowser] found {service.Key}:{service.Value}");
|
||||||
if (service.Key.Equals(QBonjour.TCPService))
|
if (service.Key.Equals(QBonjour.TCPService))
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ namespace QControlKit
|
|||||||
|
|
||||||
public void sendMessage(string address, params object[] args)
|
public void sendMessage(string address, params object[] args)
|
||||||
{
|
{
|
||||||
tcpClient.Send(new OscMessage(address, args));
|
tcpClient.QueueForSending(new OscMessage(address, args));
|
||||||
Log.Debug($"[client] send message {address} : {args}");
|
Log.Debug($"[client] send message {address} : {args}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netstandard2.0</TargetFramework>
|
<TargetFramework>netstandard2.1</TargetFramework>
|
||||||
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
|
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
|
||||||
<Authors>Joel Wetzell</Authors>
|
<Authors>Joel Wetzell</Authors>
|
||||||
<Version>1.0.0-devel</Version>
|
<Version>1.0.0-devel</Version>
|
||||||
@@ -16,14 +16,18 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Serilog" Version="2.10.0" />
|
<PackageReference Include="Serilog" Version="2.10.0" />
|
||||||
<PackageReference Include="Zeroconf" Version="3.5.11" />
|
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
||||||
|
<PackageReference Include="Zeroconf" Version="3.5.11" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Folder Include="Constants\" />
|
<Folder Include="Constants\" />
|
||||||
<Folder Include="Cue\" />
|
<Folder Include="Cue\" />
|
||||||
|
<Folder Include="SharpOSC\" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Remove="Cue\" />
|
<None Remove="Cue\" />
|
||||||
|
<None Remove="SharpOSC" />
|
||||||
|
<None Remove="Zeroconf" />
|
||||||
|
<None Remove="SharpOSC\" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -31,7 +31,12 @@ 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 Queue<OscPacket> SendQueue = new Queue<OscPacket>();
|
||||||
|
|
||||||
private Thread receivingThread;
|
private Thread receivingThread;
|
||||||
|
private Thread sendThread;
|
||||||
|
|
||||||
string _address;
|
string _address;
|
||||||
TcpClient client;
|
TcpClient client;
|
||||||
|
|
||||||
@@ -54,6 +59,10 @@ namespace SharpOSC
|
|||||||
client = new TcpClient(Address, Port);
|
client = new TcpClient(Address, Port);
|
||||||
receivingThread = new Thread(ReceiveLoop);
|
receivingThread = new Thread(ReceiveLoop);
|
||||||
receivingThread.Start();
|
receivingThread.Start();
|
||||||
|
|
||||||
|
sendThread = new Thread(SendLoop);
|
||||||
|
sendThread.Start();
|
||||||
|
|
||||||
Log.Debug($"[tcpclient] connected to <{Address}:{Port}>");
|
Log.Debug($"[tcpclient] connected to <{Address}:{Port}>");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -65,6 +74,23 @@ namespace SharpOSC
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void QueueForSending(OscPacket packet)
|
||||||
|
{
|
||||||
|
SendQueue.Enqueue(packet);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SendLoop()
|
||||||
|
{
|
||||||
|
while (client != null && client.Connected)
|
||||||
|
{
|
||||||
|
if(SendQueue.Count > 0)
|
||||||
|
{
|
||||||
|
OscPacket packet = SendQueue.Dequeue();
|
||||||
|
Send(packet);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void Send(byte[] message)
|
public void Send(byte[] message)
|
||||||
{
|
{
|
||||||
byte[] slipData = SlipEncode(message);
|
byte[] slipData = SlipEncode(message);
|
||||||
@@ -91,7 +117,7 @@ namespace SharpOSC
|
|||||||
|
|
||||||
public void ReceiveLoop()
|
public void ReceiveLoop()
|
||||||
{
|
{
|
||||||
while (client.Connected)
|
while (client != null && client.Connected)
|
||||||
{
|
{
|
||||||
Receive();
|
Receive();
|
||||||
}
|
}
|
||||||
@@ -124,10 +150,11 @@ namespace SharpOSC
|
|||||||
} while (netStream.DataAvailable);
|
} while (netStream.DataAvailable);
|
||||||
|
|
||||||
//Console.WriteLine("Raw TCP In: " + System.Text.Encoding.UTF8.GetString(responseData.ToArray()));
|
//Console.WriteLine("Raw TCP In: " + System.Text.Encoding.UTF8.GetString(responseData.ToArray()));
|
||||||
OscMessage response = (OscMessage)OscPacket.GetPacket(responseData.Skip(1).ToArray());
|
OscPacket packet = OscPacket.GetPacket(responseData.Skip(1).ToArray());
|
||||||
|
OscMessage responseMessage = (OscMessage)packet;
|
||||||
//watch.Stop();
|
//watch.Stop();
|
||||||
//Console.WriteLine($"TCPCLient - message receive took {watch.ElapsedMilliseconds}ms and {reads} reads");
|
//Console.WriteLine($"TCPCLient - message receive took {watch.ElapsedMilliseconds}ms and {reads} reads");
|
||||||
OnMessageReceived(response);
|
OnMessageReceived(responseMessage);
|
||||||
}
|
}
|
||||||
} catch(Exception e)
|
} catch(Exception e)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -57,7 +57,7 @@
|
|||||||
<PackageReference Include="Serilog.Sinks.Xamarin">
|
<PackageReference Include="Serilog.Sinks.Xamarin">
|
||||||
<Version>0.2.0.64</Version>
|
<Version>0.2.0.64</Version>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="Xamarin.Forms" Version="5.0.0.2083" />
|
<PackageReference Include="Xamarin.Forms" Version="5.0.0.2244" />
|
||||||
<PackageReference Include="Xamarin.Essentials" Version="1.7.0" />
|
<PackageReference Include="Xamarin.Essentials" Version="1.7.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -2,37 +2,43 @@
|
|||||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
<plist version="1.0">
|
<plist version="1.0">
|
||||||
<dict>
|
<dict>
|
||||||
<key>UIDeviceFamily</key>
|
<key>UIDeviceFamily</key>
|
||||||
<array>
|
<array>
|
||||||
<integer>1</integer>
|
<integer>1</integer>
|
||||||
<integer>2</integer>
|
<integer>2</integer>
|
||||||
</array>
|
</array>
|
||||||
<key>UISupportedInterfaceOrientations</key>
|
<key>UISupportedInterfaceOrientations</key>
|
||||||
<array>
|
<array>
|
||||||
<string>UIInterfaceOrientationPortrait</string>
|
<string>UIInterfaceOrientationPortrait</string>
|
||||||
<string>UIInterfaceOrientationLandscapeLeft</string>
|
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||||
<string>UIInterfaceOrientationLandscapeRight</string>
|
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||||
</array>
|
</array>
|
||||||
<key>UISupportedInterfaceOrientations~ipad</key>
|
<key>UISupportedInterfaceOrientations~ipad</key>
|
||||||
<array>
|
<array>
|
||||||
<string>UIInterfaceOrientationPortrait</string>
|
<string>UIInterfaceOrientationPortrait</string>
|
||||||
<string>UIInterfaceOrientationPortraitUpsideDown</string>
|
<string>UIInterfaceOrientationPortraitUpsideDown</string>
|
||||||
<string>UIInterfaceOrientationLandscapeLeft</string>
|
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||||
<string>UIInterfaceOrientationLandscapeRight</string>
|
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||||
</array>
|
</array>
|
||||||
<key>MinimumOSVersion</key>
|
<key>MinimumOSVersion</key>
|
||||||
<string>8.0</string>
|
<string>8.0</string>
|
||||||
<key>CFBundleDisplayName</key>
|
<key>CFBundleDisplayName</key>
|
||||||
<string>QControlKitXamDemo</string>
|
<string>QControlKitXamDemo</string>
|
||||||
<key>CFBundleIdentifier</key>
|
<key>CFBundleIdentifier</key>
|
||||||
<string>com.companyname.QControlKitXamDemo</string>
|
<string>com.companyname.QControlKitXamDemo</string>
|
||||||
<key>CFBundleVersion</key>
|
<key>CFBundleVersion</key>
|
||||||
<string>1.0</string>
|
<string>1.0</string>
|
||||||
<key>UILaunchStoryboardName</key>
|
<key>UILaunchStoryboardName</key>
|
||||||
<string>LaunchScreen</string>
|
<string>LaunchScreen</string>
|
||||||
<key>CFBundleName</key>
|
<key>CFBundleName</key>
|
||||||
<string>QControlKitXamDemo</string>
|
<string>QControlKitXamDemo</string>
|
||||||
<key>XSAppIconAssets</key>
|
<key>XSAppIconAssets</key>
|
||||||
<string>Assets.xcassets/AppIcon.appiconset</string>
|
<string>Assets.xcassets/AppIcon.appiconset</string>
|
||||||
|
<key>NSBonjourServices</key>
|
||||||
|
<array>
|
||||||
|
<string>_qlab._tcp</string>
|
||||||
|
</array>
|
||||||
|
<key>NSLocalNetworkUsageDescription</key>
|
||||||
|
<string>Scan network for QLab instances</string>
|
||||||
</dict>
|
</dict>
|
||||||
</plist>
|
</plist>
|
||||||
|
|||||||
@@ -51,6 +51,7 @@
|
|||||||
<CodesignEntitlements>Entitlements.plist</CodesignEntitlements>
|
<CodesignEntitlements>Entitlements.plist</CodesignEntitlements>
|
||||||
<MtouchLink>None</MtouchLink>
|
<MtouchLink>None</MtouchLink>
|
||||||
<MtouchInterpreter>-all</MtouchInterpreter>
|
<MtouchInterpreter>-all</MtouchInterpreter>
|
||||||
|
<CodesignProvision>Wildcard</CodesignProvision>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhone' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhone' ">
|
||||||
<DebugType>none</DebugType>
|
<DebugType>none</DebugType>
|
||||||
@@ -130,7 +131,7 @@
|
|||||||
<PackageReference Include="Serilog.Sinks.Xamarin">
|
<PackageReference Include="Serilog.Sinks.Xamarin">
|
||||||
<Version>0.2.0.64</Version>
|
<Version>0.2.0.64</Version>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="Xamarin.Forms" Version="5.0.0.2083" />
|
<PackageReference Include="Xamarin.Forms" Version="5.0.0.2244" />
|
||||||
<PackageReference Include="Xamarin.Essentials" Version="1.7.0" />
|
<PackageReference Include="Xamarin.Essentials" Version="1.7.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets" />
|
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets" />
|
||||||
|
|||||||
@@ -30,7 +30,11 @@ namespace QControlKitXamDemo
|
|||||||
{
|
{
|
||||||
Task.Run(async () =>
|
Task.Run(async () =>
|
||||||
{
|
{
|
||||||
browser.ProbeForQLabInstances();
|
Device.BeginInvokeOnMainThread(() =>
|
||||||
|
{
|
||||||
|
browser.ProbeForQLabInstances();
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Serilog" Version="2.10.0" />
|
<PackageReference Include="Serilog" Version="2.10.0" />
|
||||||
<PackageReference Include="Xamarin.Forms" Version="5.0.0.2083" />
|
<PackageReference Include="Xamarin.Forms" Version="5.0.0.2244" />
|
||||||
<PackageReference Include="Xamarin.Essentials" Version="1.7.0" />
|
<PackageReference Include="Xamarin.Essentials" Version="1.7.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user