mirror of
https://github.com/jwetzell/QControlKit.git
synced 2026-08-12 19:03:45 +00:00
Rework workspace/client/tcpclient disconnection
This commit is contained in:
+1
-1
@@ -99,7 +99,7 @@ namespace QSharp
|
||||
{
|
||||
foreach(var server in servers)
|
||||
{
|
||||
server.Close();
|
||||
server.disconnect();
|
||||
}
|
||||
zeroconfTCPBrowser.Dispose();
|
||||
}
|
||||
|
||||
+1
-9
@@ -241,14 +241,6 @@ namespace QSharp
|
||||
}
|
||||
WorkspacesUpdated(this, new QWorkspacesUpdatedArgs { Workspaces = workspaces });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void Close()
|
||||
{
|
||||
this.tcpClient.Close();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+7
-4
@@ -71,14 +71,17 @@ namespace QSharp
|
||||
}
|
||||
#endregion
|
||||
|
||||
public void Close()
|
||||
public void disconnect()
|
||||
{
|
||||
foreach (var workspace in workspaces)
|
||||
{
|
||||
if(workspace.connected)
|
||||
workspace.Close();
|
||||
if (workspace.connected)
|
||||
{
|
||||
Log.Debug($"[server] Close Called For workspace: {workspace.name}");
|
||||
workspace.disconnect();
|
||||
}
|
||||
}
|
||||
client.Close();
|
||||
client.disconnect();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -180,15 +180,16 @@ namespace QSharp
|
||||
|
||||
public void disconnect()
|
||||
{
|
||||
//TODO
|
||||
Log.Information($"[workspace] disconnect: {name}");
|
||||
stopHeartbeat();
|
||||
if (heartbeatTimer != null)
|
||||
stopHeartbeat();
|
||||
stopReceivingUpdates();
|
||||
disconnectFromWorkspace();
|
||||
|
||||
connected = false;
|
||||
|
||||
client.disconnect();
|
||||
|
||||
//TODO
|
||||
//root.removeAllChildCues();
|
||||
|
||||
}
|
||||
@@ -531,11 +532,6 @@ namespace QSharp
|
||||
|
||||
#endregion
|
||||
|
||||
public void Close()
|
||||
{
|
||||
client.Close();
|
||||
}
|
||||
|
||||
#region Printing
|
||||
public void Print()
|
||||
{
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Net.Sockets;
|
||||
using System.Threading;
|
||||
using Serilog;
|
||||
|
||||
namespace SharpOSC
|
||||
{
|
||||
@@ -30,7 +31,7 @@ namespace SharpOSC
|
||||
}
|
||||
public delegate void MessageReceivedHandler(object source, MessageEventArgs args);
|
||||
public event MessageReceivedHandler MessageReceived;
|
||||
|
||||
private Thread receivingThread;
|
||||
string _address;
|
||||
TcpClient client;
|
||||
|
||||
@@ -51,9 +52,9 @@ namespace SharpOSC
|
||||
try
|
||||
{
|
||||
client = new TcpClient(Address, Port);
|
||||
Thread receivingThread = new Thread(ReceiveLoop);
|
||||
receivingThread = new Thread(ReceiveLoop);
|
||||
receivingThread.Start();
|
||||
//Console.WriteLine($"TCPClient - connected to <{Address}:{Port}>");
|
||||
Console.WriteLine($"[tcpclient] connected to <{Address}:{Port}>");
|
||||
return true;
|
||||
}
|
||||
catch (Exception e)
|
||||
@@ -94,7 +95,7 @@ namespace SharpOSC
|
||||
{
|
||||
Receive();
|
||||
}
|
||||
Console.WriteLine("TCPClient - Receive Loop has exited for some reason");
|
||||
//Log.Debug("[tcpclient] - ReceiveLoop has exited");
|
||||
}
|
||||
|
||||
public void Receive()
|
||||
@@ -164,10 +165,13 @@ namespace SharpOSC
|
||||
|
||||
public void Close()
|
||||
{
|
||||
if(client != null || !client.Connected)
|
||||
if (client != null)
|
||||
{
|
||||
client.GetStream().Close();
|
||||
client.Close();
|
||||
if (client.Connected)
|
||||
{
|
||||
client.GetStream().Close();
|
||||
client.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user