How to use the tstl.is_node function in tstl

To help you get started, we’ve selected a few tstl examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github samchon / framework / src / protocol / communicator / server_connector / WebServerConnector.ts View on Github external
// COMPOSITE FULL-ADDRESS
		let address: string;

		if (ip.indexOf("ws://") == -1)
			if (ip.indexOf("://") != -1)
				throw "only websocket is possible";
			else
				ip = "ws://" + ip;

		if (path.length != 0 && path.charAt(0) != "/")
			path = "/" + path;

		address = ip + ":" + port + path;

		// CONNECTION BRANCHES
		if (std.is_node() == true)
		{
			this.node_client_ = new ws.client();
			this.node_client_.on("connect", this._Handle_node_connect.bind(this));

			this.node_client_.connect(address);
		}
		else
		{
			this.browser_socket_ = new WebSocket(address);
			
			this.browser_socket_.onopen = this._Handle_browser_connect.bind(this);
			this.browser_socket_.onerror = this._Handle_close.bind(this);
			this.browser_socket_.onclose = this._Handle_close.bind(this);
			this.browser_socket_.onmessage = this._Handle_browser_message.bind(this);
		}
	}
github samchon / framework / src / protocol / communicator / server_connector / WebServerConnector.ts View on Github external
public close(): void
	{
		if (std.is_node() == true)
			super.close();
		else
			this.browser_socket_.close();
	}