mirror of
https://github.com/jwetzell/QControlKit.git
synced 2026-08-03 06:27:59 +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()
|
||||
{
|
||||
Log.Debug("[qbrowser] probing for instances");
|
||||
|
||||
IReadOnlyList<IZeroconfHost> results = await
|
||||
ZeroconfResolver.ResolveAsync(QBonjour.TCPService,TimeSpan.FromSeconds(3));
|
||||
|
||||
foreach (var zeroconfHost in results)
|
||||
{
|
||||
Log.Debug($"[qbrowser] found host {zeroconfHost.IPAddress}:{zeroconfHost.DisplayName}");
|
||||
foreach (var service in zeroconfHost.Services)
|
||||
{
|
||||
Log.Debug($"[qbrowser] found {service.Key}:{service.Value}");
|
||||
if (service.Key.Equals(QBonjour.TCPService))
|
||||
{
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ namespace QControlKit
|
||||
|
||||
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}");
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<TargetFramework>netstandard2.1</TargetFramework>
|
||||
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
|
||||
<Authors>Joel Wetzell</Authors>
|
||||
<Version>1.0.0-devel</Version>
|
||||
@@ -16,14 +16,18 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Serilog" Version="2.10.0" />
|
||||
<PackageReference Include="Zeroconf" Version="3.5.11" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
||||
<PackageReference Include="Zeroconf" Version="3.5.11" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Constants\" />
|
||||
<Folder Include="Cue\" />
|
||||
<Folder Include="SharpOSC\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Remove="Cue\" />
|
||||
<None Remove="SharpOSC" />
|
||||
<None Remove="Zeroconf" />
|
||||
<None Remove="SharpOSC\" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
||||
@@ -31,7 +31,12 @@ namespace SharpOSC
|
||||
}
|
||||
public delegate void MessageReceivedHandler(object source, MessageEventArgs args);
|
||||
public event MessageReceivedHandler MessageReceived;
|
||||
|
||||
private Queue<OscPacket> SendQueue = new Queue<OscPacket>();
|
||||
|
||||
private Thread receivingThread;
|
||||
private Thread sendThread;
|
||||
|
||||
string _address;
|
||||
TcpClient client;
|
||||
|
||||
@@ -54,6 +59,10 @@ namespace SharpOSC
|
||||
client = new TcpClient(Address, Port);
|
||||
receivingThread = new Thread(ReceiveLoop);
|
||||
receivingThread.Start();
|
||||
|
||||
sendThread = new Thread(SendLoop);
|
||||
sendThread.Start();
|
||||
|
||||
Log.Debug($"[tcpclient] connected to <{Address}:{Port}>");
|
||||
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)
|
||||
{
|
||||
byte[] slipData = SlipEncode(message);
|
||||
@@ -91,7 +117,7 @@ namespace SharpOSC
|
||||
|
||||
public void ReceiveLoop()
|
||||
{
|
||||
while (client.Connected)
|
||||
while (client != null && client.Connected)
|
||||
{
|
||||
Receive();
|
||||
}
|
||||
@@ -124,10 +150,11 @@ namespace SharpOSC
|
||||
} while (netStream.DataAvailable);
|
||||
|
||||
//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();
|
||||
//Console.WriteLine($"TCPCLient - message receive took {watch.ElapsedMilliseconds}ms and {reads} reads");
|
||||
OnMessageReceived(response);
|
||||
OnMessageReceived(responseMessage);
|
||||
}
|
||||
} catch(Exception e)
|
||||
{
|
||||
|
||||
@@ -57,7 +57,7 @@
|
||||
<PackageReference Include="Serilog.Sinks.Xamarin">
|
||||
<Version>0.2.0.64</Version>
|
||||
</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" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
||||
@@ -2,37 +2,43 @@
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>UIDeviceFamily</key>
|
||||
<array>
|
||||
<integer>1</integer>
|
||||
<integer>2</integer>
|
||||
</array>
|
||||
<key>UISupportedInterfaceOrientations</key>
|
||||
<array>
|
||||
<string>UIInterfaceOrientationPortrait</string>
|
||||
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||
</array>
|
||||
<key>UISupportedInterfaceOrientations~ipad</key>
|
||||
<array>
|
||||
<string>UIInterfaceOrientationPortrait</string>
|
||||
<string>UIInterfaceOrientationPortraitUpsideDown</string>
|
||||
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||
</array>
|
||||
<key>MinimumOSVersion</key>
|
||||
<string>8.0</string>
|
||||
<key>CFBundleDisplayName</key>
|
||||
<string>QControlKitXamDemo</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>com.companyname.QControlKitXamDemo</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1.0</string>
|
||||
<key>UILaunchStoryboardName</key>
|
||||
<string>LaunchScreen</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>QControlKitXamDemo</string>
|
||||
<key>XSAppIconAssets</key>
|
||||
<string>Assets.xcassets/AppIcon.appiconset</string>
|
||||
<key>UIDeviceFamily</key>
|
||||
<array>
|
||||
<integer>1</integer>
|
||||
<integer>2</integer>
|
||||
</array>
|
||||
<key>UISupportedInterfaceOrientations</key>
|
||||
<array>
|
||||
<string>UIInterfaceOrientationPortrait</string>
|
||||
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||
</array>
|
||||
<key>UISupportedInterfaceOrientations~ipad</key>
|
||||
<array>
|
||||
<string>UIInterfaceOrientationPortrait</string>
|
||||
<string>UIInterfaceOrientationPortraitUpsideDown</string>
|
||||
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||
</array>
|
||||
<key>MinimumOSVersion</key>
|
||||
<string>8.0</string>
|
||||
<key>CFBundleDisplayName</key>
|
||||
<string>QControlKitXamDemo</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>com.companyname.QControlKitXamDemo</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1.0</string>
|
||||
<key>UILaunchStoryboardName</key>
|
||||
<string>LaunchScreen</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>QControlKitXamDemo</string>
|
||||
<key>XSAppIconAssets</key>
|
||||
<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>
|
||||
</plist>
|
||||
|
||||
@@ -51,6 +51,7 @@
|
||||
<CodesignEntitlements>Entitlements.plist</CodesignEntitlements>
|
||||
<MtouchLink>None</MtouchLink>
|
||||
<MtouchInterpreter>-all</MtouchInterpreter>
|
||||
<CodesignProvision>Wildcard</CodesignProvision>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhone' ">
|
||||
<DebugType>none</DebugType>
|
||||
@@ -130,7 +131,7 @@
|
||||
<PackageReference Include="Serilog.Sinks.Xamarin">
|
||||
<Version>0.2.0.64</Version>
|
||||
</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" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets" />
|
||||
|
||||
@@ -30,7 +30,11 @@ namespace QControlKitXamDemo
|
||||
{
|
||||
Task.Run(async () =>
|
||||
{
|
||||
browser.ProbeForQLabInstances();
|
||||
Device.BeginInvokeOnMainThread(() =>
|
||||
{
|
||||
browser.ProbeForQLabInstances();
|
||||
});
|
||||
|
||||
});
|
||||
return true;
|
||||
});
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<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" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user