Make TcpClient connection method timeout

This commit is contained in:
2020-06-13 10:49:31 -05:00
parent ccc2df2fc4
commit a5ff4c05d6
4 changed files with 19 additions and 23 deletions
-8
View File
@@ -29,10 +29,6 @@
<AndroidSupportedAbis>x86;armeabi-v7a;arm64-v8a;x86_64</AndroidSupportedAbis> <AndroidSupportedAbis>x86;armeabi-v7a;arm64-v8a;x86_64</AndroidSupportedAbis>
<MandroidI18n> <MandroidI18n>
</MandroidI18n> </MandroidI18n>
<AotAssemblies>false</AotAssemblies>
<EnableLLVM>false</EnableLLVM>
<AndroidEnableProfiledAot>false</AndroidEnableProfiledAot>
<BundleAssemblies>false</BundleAssemblies>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
@@ -54,10 +50,6 @@
<AndroidSigningKeyPass> <AndroidSigningKeyPass>
</AndroidSigningKeyPass> </AndroidSigningKeyPass>
<AndroidSupportedAbis>armeabi-v7a;x86;arm64-v8a;x86_64</AndroidSupportedAbis> <AndroidSupportedAbis>armeabi-v7a;x86;arm64-v8a;x86_64</AndroidSupportedAbis>
<AotAssemblies>false</AotAssemblies>
<EnableLLVM>false</EnableLLVM>
<AndroidEnableProfiledAot>false</AndroidEnableProfiledAot>
<BundleAssemblies>false</BundleAssemblies>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="System" /> <Reference Include="System" />
+2 -2
View File
@@ -52,13 +52,13 @@
<OutputPath>bin\iPhoneSimulator\Release</OutputPath> <OutputPath>bin\iPhoneSimulator\Release</OutputPath>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<CodesignKey>iPhone Developer: Joel Wetzell (5E8CU66YWB)</CodesignKey> <CodesignKey>iPhone Distribution: Joel Wetzell (JHA7H7P56J)</CodesignKey>
<MtouchNoSymbolStrip>true</MtouchNoSymbolStrip> <MtouchNoSymbolStrip>true</MtouchNoSymbolStrip>
<MtouchLink>None</MtouchLink> <MtouchLink>None</MtouchLink>
<MtouchArch>x86_64</MtouchArch> <MtouchArch>x86_64</MtouchArch>
<MtouchHttpClientHandler>HttpClientHandler</MtouchHttpClientHandler> <MtouchHttpClientHandler>HttpClientHandler</MtouchHttpClientHandler>
<PlatformTarget>x86</PlatformTarget> <PlatformTarget>x86</PlatformTarget>
<CodesignProvision>VS: com.jwetzell.qController Development</CodesignProvision> <CodesignProvision>qController</CodesignProvision>
<MtouchExtraArgs>-v -v -v -v</MtouchExtraArgs> <MtouchExtraArgs>-v -v -v -v</MtouchExtraArgs>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhone' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhone' ">
@@ -48,19 +48,16 @@ namespace SharpOSC
public bool Connect() public bool Connect()
{ {
try client = new TcpClient();
if (!client.ConnectAsync(Address, Port).Wait(TimeSpan.FromSeconds(1)))
{ {
client = new TcpClient(Address, Port);
Thread receivingThread = new Thread(ReceiveLoop);
receivingThread.Start();
//Console.WriteLine($"TCPClient - connected to <{Address}:{Port}>");
return true;
}
catch (Exception e)
{
Console.WriteLine(e.Message);
return false; return false;
} }
Thread receivingThread = new Thread(ReceiveLoop);
receivingThread.Start();
return true;
} }
@@ -161,8 +158,12 @@ namespace SharpOSC
public void Close() public void Close()
{ {
client.GetStream().Close(); if (client.Connected)
client.Close(); {
client.GetStream().Close();
client.Close();
}
} }
protected virtual void OnMessageReceived(OscMessage msg) protected virtual void OnMessageReceived(OscMessage msg)
@@ -45,7 +45,10 @@ namespace qController
App.showToast("Error connecting...make sure QLab is running"); App.showToast("Error connecting...make sure QLab is running");
Back(); Back();
} }
qController.KickOff(); else
{
qController.KickOff();
}
} }
private void OnWorkspaceSelected(object source, WorkspacePromptArgs args) private void OnWorkspaceSelected(object source, WorkspacePromptArgs args)