serverWebSocketUri property

  1. @Since('2.14')
Uri? serverWebSocketUri

The Uri to connect to the service via web socket. If the web server is not running, this will be null.

Implementation

@Since('2.14')
Uri? get serverWebSocketUri {
  Uri? uri = serverUri;
  if (uri != null) {
    final pathSegments = <String>[];
    if (uri.pathSegments.isNotEmpty) {
      pathSegments.addAll(uri.pathSegments.where(
        // Strip out the empty string that appears at the end of path segments.
        // Empty string elements will result in an extra '/' being added to the
        // URI.
        (s) => s.isNotEmpty,
      ));
    }
    pathSegments.add('ws');
    uri = uri.replace(scheme: 'ws', pathSegments: pathSegments);
  }
  return uri;
}