protected async Task Init() { if (persistent) { serverLink = await CreateLink().ConfigureAwait(false); } }
protected async Task <bool> PreCall(string serviceMd5Sum) { if (disposed) { throw new ObjectDisposedException("ServiceClient instance was disposed"); } if (serviceMd5Sum != md5sum) { throw new Exception($"Call to service '{serviceName}' with md5sum '{serviceMd5Sum}' does not match the md5sum that was specified when the handle was created ('{md5sum}')."); } if (serverLink != null && !serverLink.IsValid) { if (persistent) { logger.LogWarning("Persistent service client's server link has been dropped. Trying to reconnect to proceed with this call."); } ServiceManager.Instance.RemoveServiceServerLinkAsync(serverLink); serverLink.Dispose(); serverLink = null; } if (serverLink == null) { serverLink = await CreateLink().ConfigureAwait(false); } return(true); }
protected bool precall(string service_md5sum) { if (service_md5sum != md5sum) { ROS.Error()($"[{ThisNode.Name}] Call to service [{service} with md5sum [{service_md5sum} does not match md5sum when the handle was created([{md5sum}])"); return(false); } if (server_link != null && server_link.connection.dropped) { if (persistent) { ROS.Warn()($"[{ThisNode.Name}] Persistent service client's server link has been dropped. Trying to reconnect to proceed with this call"); } server_link = null; } if (is_shutdown && persistent) { ROS.Warn()($"[{ThisNode.Name}] Persistent service client is self-resurrecting"); } is_shutdown = false; if (persistent && server_link == null || !persistent) { server_link = linkmaker(); } return(true); }
internal void RemoveServiceServerLinkAsync(IServiceServerLink link) { lock (gate) { serviceServerLinksAsync.Remove(link); } link.Dispose(); }
public void shutdown() { if (!is_shutdown) { is_shutdown = true; if (!persistent && server_link != null) { ServiceManager.Instance.RemoveServiceServerLink(server_link); server_link = null; } } }
internal void RemoveServiceServerLink(IServiceServerLink issl) { if (shuttingDown) { return; } lock ( serviceServerLinksMutex ) { if (serviceServerLinks.Contains(issl)) { serviceServerLinks.Remove(issl); } } }
public void Dispose() { if (disposed) { return; } disposed = true; if (serverLink != null) { ServiceManager.Instance.RemoveServiceServerLinkAsync(serverLink); serverLink.Dispose(); serverLink = null; } }