UNPKG

@xmobitea/gn-typescript-client

Version:

GearN Typescript Client SDK by XmobiTea (Pro)

157 lines (156 loc) 4.69 kB
import { LogType } from "./../logger/GNDebug"; export var MessageType; (function (MessageType) { MessageType[MessageType["Json"] = 1] = "Json"; MessageType[MessageType["MsgPack"] = 2] = "MsgPack"; })(MessageType || (MessageType = {})); export class GNServerSettings { constructor() { this.serverAddress = "127.0.0.1"; this.serverPort = 2202; this.serverSocketPort = 2901; this.useSsl = false; this.useSocket = true; this.useHttp = true; this.defaultTimeoutInSeconds = 20; this.messageType = MessageType.MsgPack; this.sendRate = 20; this.reconnectDelay = 5000; this.pingInterval = 20000; this.pingTimeout = 20000; this.logType = LogType.All; this.useReverseProxy = false; } config(options) { this.serverAddress = options.serverAddress; this.serverPort = options.serverPort; this.serverSocketPort = options.serverSocketPort; this.useSsl = options.useSsl; this.useSocket = options.useSocket; this.useHttp = options.useHttp; this.defaultTimeoutInSeconds = options.defaultTimeoutInSeconds; this.messageType = options.messageType; this.sendRate = options.sendRate; this.reconnectDelay = options.reconnectDelay; this.pingInterval = options.pingInterval; this.pingTimeout = options.pingTimeout; this.adminSecretKey = options.adminSecretKey; this.serverSecretKey = options.serverSecretKey; this.clientSecretKey = options.clientSecretKey; this.logType = options.logType; } getServerAddress() { return this.serverAddress; } setServerAddress(serverAddress) { this.serverAddress = serverAddress; } getServerPort() { return this.serverPort; } setServerPort(serverPort) { this.serverPort = serverPort; } getServerSocketPort() { return this.serverSocketPort; } setServerSocketPort(serverSocketPort) { this.serverSocketPort = serverSocketPort; } isUseSsl() { return this.useSsl; } setUseSsl(useSsl) { this.useSsl = useSsl; } isUseSocket() { return this.useSocket; } setUseSocket(useSocket) { this.useSocket = useSocket; } isUseHttp() { return this.useHttp; } setUseHttp(useHttp) { this.useHttp = useHttp; } getDefaultTimeoutInSeconds() { return this.defaultTimeoutInSeconds; } setDefaultTimeoutInSeconds(defaultTimeoutInSeconds) { this.defaultTimeoutInSeconds = defaultTimeoutInSeconds; } getMessageType() { return this.messageType; } setMessageType(messageType) { this.messageType = messageType; } getSendRate() { return this.sendRate; } setSendRate(sendRate) { this.sendRate = sendRate; } getReconnectDelay() { return this.reconnectDelay; } setReconnectDelay(reconnectDelay) { this.reconnectDelay = reconnectDelay; } getPingInterval() { return this.pingInterval; } setPingInterval(pingInterval) { this.pingInterval = pingInterval; } getPingTimeout() { return this.pingTimeout; } setPingTimeout(pingTimeout) { this.pingTimeout = pingTimeout; } getAdminSecretKey() { return this.adminSecretKey; } setAdminSecretKey(adminSecretKey) { this.adminSecretKey = adminSecretKey; } getServerSecretKey() { return this.serverSecretKey; } setServerSecretKey(serverSecretKey) { this.serverSecretKey = serverSecretKey; } getClientSecretKey() { return this.clientSecretKey; } setClientSecretKey(clientSecretKey) { this.clientSecretKey = clientSecretKey; } getLogType() { return this.logType; } setLogType(logType) { this.logType = logType; } getSocketUrl() { if (this.serverSocketPort < 0) return (this.useSsl ? "https" : "http") + "://" + this.serverAddress; else return (this.useSsl ? "https" : "http") + "://" + this.serverAddress + ":" + this.serverSocketPort; } getHttpUrl() { if (this.serverPort < 0) return (this.useSsl ? "https" : "http") + "://" + this.serverAddress; else return (this.useSsl ? "https" : "http") + "://" + this.serverAddress + ":" + this.serverPort; } setUseReverseProxy(useReverseProxy) { this.useReverseProxy = useReverseProxy; } getUseReverseProxy() { return this.useReverseProxy; } }