@needle-tools/engine
Version:
Needle Engine is a web-based runtime for 3D apps. It runs on your machine for development with great integrations into editors like Unity or Blender - and can be deployed onto any device! It is flexible, extensible and networking and XR are built-in.
55 lines (54 loc) • 2.73 kB
TypeScript
import type { INetworkingWebsocketUrlProvider } from "../engine/engine_networking.js";
import { Behaviour } from "./Component.js";
/**
* Provides configuration to the built-in networking system.
* This component supplies websocket URLs for establishing connections.
* It implements the {@link INetworkingWebsocketUrlProvider} interface.
*
* @category Networking
* @group Components
*/
export declare class Networking extends Behaviour implements INetworkingWebsocketUrlProvider {
/**
* The websocket URL to connect to for networking functionality.
* Can be a complete URL or a relative path that will be resolved against the current origin.
*/
url: string | null;
/**
* Name of the URL parameter that can override the websocket connection URL.
* When set, the URL will be overridden by the parameter value from the browser URL.
* For example, with `urlParameterName="ws"`, adding `?ws=ws://localhost:8080` to the browser URL will override the connection URL.
*/
urlParameterName: string | null;
/**
* Alternative URL to use when running on a local network.
* This is particularly useful for development, when the server is running on the same machine as the client.
*/
localhost: string | null;
/** @internal */
awake(): void;
/**
* Determines the websocket URL to use for networking connections.
* Processes the configured URL, applying localhost fallbacks when appropriate and
* handling URL parameter overrides if specified.
* @returns The formatted websocket URL string or null if no valid URL could be determined
* @internal
*/
getWebsocketUrl(): string | null;
/**
* Processes a URL string applying various transformations based on network environment.
* Handles relative paths and localhost fallbacks for local network environments.
* @param url The original URL to process
* @param localhostFallback Alternative URL to use when on a local network
* @returns The processed URL string or null/undefined if input was invalid
*/
static GetUrl(url: string | null | undefined, localhostFallback?: string | null): string | null | undefined;
/**
* Determines if the current connection is on a local network.
* Useful for applying different networking configurations in local development environments.
* This is the same as calling {@link isLocalNetwork}.
* @param hostname Optional hostname to check instead of the current window location
* @returns True if the connection is on a local network, false otherwise
*/
static IsLocalNetwork(hostname?: string): boolean;
}