added feature that allows client to work directly with ip and ports
This commit is contained in:
@@ -45,6 +45,9 @@ export class TrytonClient {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new Tryton client
|
* Create a new Tryton client
|
||||||
|
* @param config Configuration object
|
||||||
|
* @param config.hostname - Hostname or IP address. Can include port (e.g., "46.62.242.210:8090")
|
||||||
|
* @param config.port - Port number (ignored if hostname includes port)
|
||||||
*/
|
*/
|
||||||
constructor(config: TrytonClientConfig) {
|
constructor(config: TrytonClientConfig) {
|
||||||
const {
|
const {
|
||||||
@@ -69,10 +72,20 @@ export class TrytonClient {
|
|||||||
this.useHttps = port === 443 || port === 8443;
|
this.useHttps = port === 443 || port === 8443;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Handle IP:Port format (e.g., "46.62.242.210:8090")
|
||||||
|
if (this.hostname.includes(":") && !this.hostname.startsWith("http")) {
|
||||||
|
const [ip, hostPort] = this.hostname.split(":");
|
||||||
|
this.hostname = ip;
|
||||||
|
this.port = parseInt(hostPort, 10);
|
||||||
|
// Determine https based on extracted port
|
||||||
|
this.useHttps = this.port === 443 || this.port === 8443;
|
||||||
|
} else {
|
||||||
|
this.port = port;
|
||||||
|
}
|
||||||
|
|
||||||
this.database = database;
|
this.database = database;
|
||||||
this.username = username;
|
this.username = username;
|
||||||
this.password = password || ""; // Empty string if not provided
|
this.password = password || ""; // Empty string if not provided
|
||||||
this.port = port;
|
|
||||||
this.language = language;
|
this.language = language;
|
||||||
this.options = options;
|
this.options = options;
|
||||||
this.connection = null;
|
this.connection = null;
|
||||||
@@ -81,6 +94,7 @@ export class TrytonClient {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Alternative constructor for backward compatibility
|
* Alternative constructor for backward compatibility
|
||||||
|
* Note: If hostname includes port (IP:Port), the port parameter will be ignored
|
||||||
*/
|
*/
|
||||||
static create(
|
static create(
|
||||||
hostname: string,
|
hostname: string,
|
||||||
|
|||||||
Reference in New Issue
Block a user