mirror of
https://github.com/ZuneDev/MicrosoftIris.git
synced 2026-07-27 13:13:29 -07:00
Clean up net debuggers
This commit is contained in:
@@ -186,6 +186,7 @@ namespace Microsoft.Iris
|
||||
if (debuggerFactory != null)
|
||||
{
|
||||
Debugger = debuggerFactory();
|
||||
Debugger.Start();
|
||||
DebuggerServerReady?.Invoke(Debugger, EventArgs.Empty);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.Collections.Concurrent;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Threading;
|
||||
|
||||
namespace Microsoft.Iris.Debug.SystemNet;
|
||||
|
||||
@@ -35,11 +36,7 @@ public class NetDebuggerClient : IDebuggerClient, IRemoteDebuggerState, IDisposa
|
||||
public event Action<InterpreterCommand> InterpreterStateChanged;
|
||||
public event Action<IDebuggerState, object> Connected;
|
||||
|
||||
public NetDebuggerClient(string connectionUri) : this(connectionUri is null ? null : new Uri(connectionUri))
|
||||
{
|
||||
}
|
||||
|
||||
public NetDebuggerClient(Uri connectionUri)
|
||||
public NetDebuggerClient(Uri connectionUri = null)
|
||||
{
|
||||
ConnectionUri = connectionUri ?? DebugRemoting.DEFAULT_TCP_URI;
|
||||
_socket = new(SocketType.Stream, ProtocolType.Tcp);
|
||||
@@ -48,7 +45,7 @@ public class NetDebuggerClient : IDebuggerClient, IRemoteDebuggerState, IDisposa
|
||||
|
||||
public void Start()
|
||||
{
|
||||
System.Threading.Thread connectThread = new(ConnectLoop) { IsBackground = true };
|
||||
Thread connectThread = new(ConnectLoop) { IsBackground = true };
|
||||
connectThread.Start();
|
||||
}
|
||||
|
||||
@@ -149,20 +146,22 @@ public class NetDebuggerClient : IDebuggerClient, IRemoteDebuggerState, IDisposa
|
||||
|
||||
private void ConnectLoop()
|
||||
{
|
||||
var endpoint = new IPEndPoint(IPAddress.Parse(ConnectionUri.Host), ConnectionUri.Port);
|
||||
while (!_socket.Connected)
|
||||
{
|
||||
try
|
||||
{
|
||||
var endpoint = new IPEndPoint(IPAddress.Parse(ConnectionUri.Host), ConnectionUri.Port);
|
||||
_socket.Connect(endpoint);
|
||||
}
|
||||
catch { }
|
||||
|
||||
Thread.Sleep(500);
|
||||
}
|
||||
|
||||
Connected?.Invoke(this, _socket);
|
||||
|
||||
System.Threading.Thread receiveThread = new(MessageReceiveLoop) { IsBackground = true };
|
||||
System.Threading.Thread sendThread = new(MessageSendLoop) { IsBackground = true };
|
||||
Thread receiveThread = new(MessageReceiveLoop) { IsBackground = true };
|
||||
Thread sendThread = new(MessageSendLoop) { IsBackground = true };
|
||||
receiveThread.Start();
|
||||
sendThread.Start();
|
||||
}
|
||||
|
||||
@@ -32,15 +32,11 @@ public class NetDebuggerServer : IDebuggerServer, IRemoteDebuggerState, IDisposa
|
||||
}
|
||||
}
|
||||
|
||||
public NetDebuggerServer(string connectionUri) : this(new Uri(connectionUri))
|
||||
{
|
||||
}
|
||||
|
||||
public NetDebuggerServer(Uri connectionUri)
|
||||
public NetDebuggerServer(Uri connectionUri = null)
|
||||
{
|
||||
ConnectionUri = connectionUri ?? DebugRemoting.DEFAULT_TCP_URI;
|
||||
|
||||
_listener = TcpListener.Create(connectionUri.Port);
|
||||
_listener = TcpListener.Create(ConnectionUri.Port);
|
||||
_listener.Start();
|
||||
|
||||
_formatter = DebugRemoting.CreateBsonFormatter();
|
||||
|
||||
Reference in New Issue
Block a user