private bool canConnect() { try { if (_client != null && _client.IsConnected) return true; var instance = new EngineLocator().GetInstance(_path); if (instance == null) return false; Logger.Write("Connecting to port {0} hosted by {1} with token {2}", instance.Port, instance.ProcessID, instance.File); _client = new SocketClient(); _client.Connect(instance.Port, (m) => { if (RecievedMessage != null && m != null && m.Trim().Length > 0) RecievedMessage(this, new MessageArgs(Guid.Empty, m)); }); if (_client.IsConnected) { Logger.Write("Connecting to editor on port: {0}", instance.Port); return true; } _client = null; return false; } catch (Exception ex) { Logger.Write(ex); return false; } }
public void Connect(string path) { _path = path; if (_client != null &&_client.IsConnected) _client.Disconnect(); _client = null; isConnected(); }
public void Connect(string path) { Logger.Write("Trying to connect to " + path); _path = path; if (_client != null &&_client.IsConnected) _client.Disconnect(); _client = null; isConnected(); }
private bool isConnected() { try { if (_client != null && _client.IsConnected) return true; var instance = new EngineLocator().GetInstance(_path); if (instance == null) return false; _client = new SocketClient(); _client.Connect(instance.Port, (m) => { if (RecievedMessage != null) RecievedMessage(this, new MessageArgs(Guid.Empty, m)); }); if (_client.IsConnected) return true; _client = null; return false; } catch { return false; } }
private bool canConnectTo(Instance info) { var client = new SocketClient(); client.Connect(info.Port, (s) => {}); var connected = client.IsConnected; client.Disconnect(); if (!connected) File.Delete(info.File); return connected; }
public void Dispose() { if (_client != null && _client.IsConnected) _client.Disconnect(); _client = null; }
private bool canConnectTo(Instance info) { var client = new SocketClient(); client.Connect(info.Port, (s) => {}); var connected = client.IsConnected; client.Disconnect(); if (!connected) { try { Process.GetProcessById(info.ProcessID); } catch { File.Delete(info.File); } } return connected; }