@jibb-open/jssdk 3.17.7 → 3.18.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/api/auth.js +126 -1
- package/api/cisco.js +37 -1
- package/api/eventbus.js +150 -1
- package/api/index.js +21 -1
- package/api/meeting.js +332 -1
- package/api/recording.js +55 -1
- package/api/user.js +24 -1
- package/api/webexbot.js +23 -1
- package/api/whiteboard.js +116 -1
- package/config.js +9 -1
- package/package.json +3 -1
- package/types/exceptions.js +68 -1
- package/types/jibb.pb.js +6100 -1
- package/types/proto.js +5 -1
- package/types/types.js +167 -1
- package/utils/cached_variable.js +18 -1
- package/utils/future.js +24 -1
- package/utils/http/http.axios.js +38 -1
- package/utils/http/index.js +9 -1
- package/utils/index.js +4 -1
- package/utils/logger/index.js +9 -1
- package/utils/logger/logger.empty.js +9 -1
- package/utils/logger/logger.pino.js +12 -1
- package/ws/connection_base.js +125 -1
- package/ws/eventbus.js +293 -1
- package/ws/index.js +11 -1
- package/ws/ipsa.js +161 -1
- package/ws/meeting.js +179 -1
- package/ws/observable_connection.js +91 -1
- package/ws/retry_connection.js +107 -1
package/types/proto.js
CHANGED
|
@@ -1 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import root from "./jibb.pb.js";
|
|
2
|
+
export const ipsa = root.jibb.ipsa.v1;
|
|
3
|
+
export const types = root.types;
|
|
4
|
+
export const cilix = root.cilix;
|
|
5
|
+
export const meeting = root.meeting;
|
package/types/types.js
CHANGED
|
@@ -1 +1,167 @@
|
|
|
1
|
-
|
|
1
|
+
import "core-js/modules/es.weak-map.js";
|
|
2
|
+
import "core-js/modules/web.dom-collections.iterator.js";
|
|
3
|
+
function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
|
|
4
|
+
function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
|
|
5
|
+
function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
|
|
6
|
+
function _classPrivateFieldGet(s, a) { return s.get(_assertClassBrand(s, a)); }
|
|
7
|
+
function _classPrivateFieldSet(s, a, r) { return s.set(_assertClassBrand(s, a), r), r; }
|
|
8
|
+
function _assertClassBrand(e, t, n) { if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n; throw new TypeError("Private element is not present on this object"); }
|
|
9
|
+
import jwt_decode from "jwt-decode";
|
|
10
|
+
export const MeetingTypes = {
|
|
11
|
+
DEFAULT: 0,
|
|
12
|
+
WHITEBOARD: 1
|
|
13
|
+
};
|
|
14
|
+
export const AccessLevel = {
|
|
15
|
+
USER: "USER",
|
|
16
|
+
ADMIN: "ADMIN",
|
|
17
|
+
SUPERADMIN: "SUPERADMIN"
|
|
18
|
+
};
|
|
19
|
+
export const UserType = {
|
|
20
|
+
UNKNOWN: 0,
|
|
21
|
+
MEMBER: 2,
|
|
22
|
+
ADMIN: 3,
|
|
23
|
+
OWNER: 4
|
|
24
|
+
};
|
|
25
|
+
export const Action = {
|
|
26
|
+
NEW: "NEW",
|
|
27
|
+
CANCEL: "CANCEL",
|
|
28
|
+
CHANGE: "CHANGE"
|
|
29
|
+
};
|
|
30
|
+
export const RenewalTerm = {
|
|
31
|
+
MANUAL: "0",
|
|
32
|
+
AUTO: "12"
|
|
33
|
+
};
|
|
34
|
+
export const SkuAction = {
|
|
35
|
+
ADD: "0",
|
|
36
|
+
MODIFIED: "1",
|
|
37
|
+
DELETE: "2",
|
|
38
|
+
NO_CHANGE: "3"
|
|
39
|
+
};
|
|
40
|
+
var _billingFrequencies = /*#__PURE__*/new WeakMap();
|
|
41
|
+
var _name = /*#__PURE__*/new WeakMap();
|
|
42
|
+
var _JibbPlan_brand = /*#__PURE__*/new WeakSet();
|
|
43
|
+
class JibbPlan {
|
|
44
|
+
constructor(name, count) {
|
|
45
|
+
_classPrivateMethodInitSpec(this, _JibbPlan_brand);
|
|
46
|
+
_classPrivateFieldInitSpec(this, _billingFrequencies, void 0);
|
|
47
|
+
_classPrivateFieldInitSpec(this, _name, void 0);
|
|
48
|
+
_classPrivateFieldSet(_name, this, name);
|
|
49
|
+
_classPrivateFieldSet(_billingFrequencies, this, new Map());
|
|
50
|
+
if (count > 0) {
|
|
51
|
+
_assertClassBrand(_JibbPlan_brand, this, _createBillingFrequencies).call(this, count);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
getPlanName() {
|
|
55
|
+
return _classPrivateFieldGet(_name, this);
|
|
56
|
+
}
|
|
57
|
+
getBillingFrequencies() {
|
|
58
|
+
return _classPrivateFieldGet(_billingFrequencies, this);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
function _createBillingFrequencies(month) {
|
|
62
|
+
for (let i = 12; i <= month; i++) {
|
|
63
|
+
let text = "Every ".concat(i, " Months");
|
|
64
|
+
_classPrivateFieldGet(_billingFrequencies, this).set(text, "".concat(i));
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
export class JibbPilot extends JibbPlan {
|
|
68
|
+
constructor() {
|
|
69
|
+
super("JIBB-Pilot", 0);
|
|
70
|
+
super.getBillingFrequencies().set('Every 3 Months', "3");
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
export class JibbRoom extends JibbPlan {
|
|
74
|
+
constructor() {
|
|
75
|
+
super("JIBB-Room", 60);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
export class JibbUser extends JibbPlan {
|
|
79
|
+
constructor() {
|
|
80
|
+
super("JIBB-User", 60);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
export class JibbStarterPack extends JibbPlan {
|
|
84
|
+
constructor() {
|
|
85
|
+
super("JIBB-Starter-Pack", 60);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
export class JibbPlans {
|
|
89
|
+
constructor() {
|
|
90
|
+
this.starterPack = new JibbStarterPack();
|
|
91
|
+
this.jibbRoom = new JibbRoom();
|
|
92
|
+
this.jibbUser = new JibbUser();
|
|
93
|
+
this.jibbPilot = new JibbPilot();
|
|
94
|
+
}
|
|
95
|
+
getAllPlan() {
|
|
96
|
+
let pList = [];
|
|
97
|
+
pList.push(this.starterPack);
|
|
98
|
+
pList.push(this.jibbRoom);
|
|
99
|
+
pList.push(this.jibbUser);
|
|
100
|
+
pList.push(this.jibbPilot);
|
|
101
|
+
return pList;
|
|
102
|
+
}
|
|
103
|
+
getAllPlanNames() {
|
|
104
|
+
let pList = [];
|
|
105
|
+
pList.push(this.starterPack.getPlanName());
|
|
106
|
+
pList.push(this.jibbRoom.getPlanName());
|
|
107
|
+
pList.push(this.jibbUser.getPlanName());
|
|
108
|
+
pList.push(this.jibbPilot.getPlanName());
|
|
109
|
+
return pList;
|
|
110
|
+
}
|
|
111
|
+
getPlan(planName) {
|
|
112
|
+
switch (planName) {
|
|
113
|
+
case this.starterPack.getPlanName():
|
|
114
|
+
return this.starterPack;
|
|
115
|
+
case this.jibbRoom.getPlanName():
|
|
116
|
+
return this.jibbRoom;
|
|
117
|
+
case this.jibbUser.getPlanName():
|
|
118
|
+
return this.jibbUser;
|
|
119
|
+
case this.jibbPilot.getPlanName():
|
|
120
|
+
return this.jibbPilot;
|
|
121
|
+
default:
|
|
122
|
+
return undefined;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
class StandardClaims {
|
|
127
|
+
constructor(token) {
|
|
128
|
+
this.token = token;
|
|
129
|
+
this.claims = jwt_decode(token);
|
|
130
|
+
this.expiryTime = new Date(this.claims.exp * 1000);
|
|
131
|
+
}
|
|
132
|
+
getSecondsUntilExpiry() {
|
|
133
|
+
let sec = this.expiryTime - Date.now();
|
|
134
|
+
return sec < 0 ? 0 : sec;
|
|
135
|
+
}
|
|
136
|
+
getHoursUntilExpiry() {
|
|
137
|
+
let sec = this.getSecondsUntilExpiry();
|
|
138
|
+
return Math.floor(sec / 3600);
|
|
139
|
+
}
|
|
140
|
+
isExpired() {
|
|
141
|
+
return this.getSecondsUntilExpiry() <= 60;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
export class MeetingClaims extends StandardClaims {
|
|
145
|
+
constructor(token) {
|
|
146
|
+
super(token);
|
|
147
|
+
this.ownerId = this.claims.data.owner_id;
|
|
148
|
+
this.meetindId = this.claims.data.meeting_id;
|
|
149
|
+
this.title = this.claims.data.title;
|
|
150
|
+
this.capacity = this.claims.data.capacity;
|
|
151
|
+
this.permission = this.claims.data.permission;
|
|
152
|
+
this.isTemporary = this.claims.data.is_temporary;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
export class UserClaims extends StandardClaims {
|
|
156
|
+
constructor(token) {
|
|
157
|
+
var _this$claims$data, _this$claims$data2, _this$claims$data3;
|
|
158
|
+
super(token);
|
|
159
|
+
this.email = (_this$claims$data = this.claims.data) === null || _this$claims$data === void 0 ? void 0 : _this$claims$data.email;
|
|
160
|
+
this.userId = this.claims.sub;
|
|
161
|
+
this.organizationId = (_this$claims$data2 = this.claims.data) === null || _this$claims$data2 === void 0 ? void 0 : _this$claims$data2.organization_id;
|
|
162
|
+
this.organizationName = (_this$claims$data3 = this.claims.data) === null || _this$claims$data3 === void 0 ? void 0 : _this$claims$data3.organization_name;
|
|
163
|
+
}
|
|
164
|
+
getUserId() {
|
|
165
|
+
return this.userId;
|
|
166
|
+
}
|
|
167
|
+
}
|
package/utils/cached_variable.js
CHANGED
|
@@ -1 +1,18 @@
|
|
|
1
|
-
|
|
1
|
+
export class CachedVariable {
|
|
2
|
+
constructor() {
|
|
3
|
+
let expirySeconds = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 60;
|
|
4
|
+
this.value = null;
|
|
5
|
+
this.expirySeconds = expirySeconds;
|
|
6
|
+
this.expiryTime = Date.now();
|
|
7
|
+
}
|
|
8
|
+
isExpired() {
|
|
9
|
+
return this.value == null || Date.now() > this.expiryTime;
|
|
10
|
+
}
|
|
11
|
+
get() {
|
|
12
|
+
if (this.isExpired()) return undefined;else return this.value;
|
|
13
|
+
}
|
|
14
|
+
set(value) {
|
|
15
|
+
this.value = value;
|
|
16
|
+
this.expiryTime = Date.now() + this.expirySeconds * 1000;
|
|
17
|
+
}
|
|
18
|
+
}
|
package/utils/future.js
CHANGED
|
@@ -1 +1,24 @@
|
|
|
1
|
-
|
|
1
|
+
import "core-js/modules/es.promise.js";
|
|
2
|
+
export class Future {
|
|
3
|
+
constructor() {
|
|
4
|
+
let self = this;
|
|
5
|
+
this.resolve = undefined;
|
|
6
|
+
this.reject = undefined;
|
|
7
|
+
this.promise = new Promise((resolve, reject) => {
|
|
8
|
+
self.resolve = resolve;
|
|
9
|
+
self.reject = reject;
|
|
10
|
+
});
|
|
11
|
+
this.promise.catch(() => {
|
|
12
|
+
return undefined;
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
get() {
|
|
16
|
+
return this.promise;
|
|
17
|
+
}
|
|
18
|
+
reject(val) {
|
|
19
|
+
this.reject(val);
|
|
20
|
+
}
|
|
21
|
+
set(val) {
|
|
22
|
+
this.resolve(val);
|
|
23
|
+
}
|
|
24
|
+
}
|
package/utils/http/http.axios.js
CHANGED
|
@@ -1 +1,38 @@
|
|
|
1
|
-
|
|
1
|
+
import "core-js/modules/es.global-this.js";
|
|
2
|
+
import "core-js/modules/es.promise.js";
|
|
3
|
+
import axios from "axios";
|
|
4
|
+
class HttpClient {
|
|
5
|
+
async get(url, headers) {
|
|
6
|
+
let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
7
|
+
options.headers = headers;
|
|
8
|
+
return axios.get(url, options);
|
|
9
|
+
}
|
|
10
|
+
async post(url) {
|
|
11
|
+
let body = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
12
|
+
let headers = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
13
|
+
return axios.post(url, body, {
|
|
14
|
+
headers: headers
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
async patch(url) {
|
|
18
|
+
let body = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
19
|
+
let headers = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
20
|
+
return axios.patch(url, body, {
|
|
21
|
+
headers: headers
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
async put(url) {
|
|
25
|
+
let body = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
26
|
+
let headers = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
27
|
+
return axios.put(url, body, {
|
|
28
|
+
headers: headers
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
async delete(url) {
|
|
32
|
+
let headers = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
33
|
+
return axios.delete(url, {
|
|
34
|
+
headers: headers
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
globalThis.http = new HttpClient();
|
package/utils/http/index.js
CHANGED
|
@@ -1 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
import "core-js/modules/es.global-this.js";
|
|
2
|
+
import "core-js/modules/es.promise.js";
|
|
3
|
+
let http = globalThis.http;
|
|
4
|
+
const initAxios = () => {
|
|
5
|
+
import("./http.axios.js").then(() => {
|
|
6
|
+
http = globalThis.http;
|
|
7
|
+
});
|
|
8
|
+
};
|
|
9
|
+
export { http, initAxios };
|
package/utils/index.js
CHANGED
package/utils/logger/index.js
CHANGED
|
@@ -1 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
import "core-js/modules/es.promise.js";
|
|
2
|
+
import { logger as emptyLogger } from "./logger.empty.js";
|
|
3
|
+
let logger = emptyLogger;
|
|
4
|
+
const initPinoLogger = () => {
|
|
5
|
+
import("./logger.pino.js").then(exports => {
|
|
6
|
+
logger = exports.logger;
|
|
7
|
+
});
|
|
8
|
+
};
|
|
9
|
+
export { logger, initPinoLogger };
|
|
@@ -1 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
class EmptyLoggerr {
|
|
2
|
+
error() {}
|
|
3
|
+
debug() {}
|
|
4
|
+
warn() {}
|
|
5
|
+
info() {}
|
|
6
|
+
setLevel() {}
|
|
7
|
+
}
|
|
8
|
+
let logger = new EmptyLoggerr();
|
|
9
|
+
export { logger };
|
|
@@ -1 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
import Pino from "pino";
|
|
2
|
+
let logger = new Pino({
|
|
3
|
+
browser: {
|
|
4
|
+
asObject: false
|
|
5
|
+
},
|
|
6
|
+
timestamp: false,
|
|
7
|
+
level: "warn"
|
|
8
|
+
});
|
|
9
|
+
logger.setLevel = level => {
|
|
10
|
+
logger.level = level;
|
|
11
|
+
};
|
|
12
|
+
export { logger };
|
package/ws/connection_base.js
CHANGED
|
@@ -1 +1,125 @@
|
|
|
1
|
-
|
|
1
|
+
import "core-js/modules/es.promise.js";
|
|
2
|
+
import "core-js/modules/es.weak-map.js";
|
|
3
|
+
import "core-js/modules/web.dom-collections.iterator.js";
|
|
4
|
+
function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
|
|
5
|
+
function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
|
|
6
|
+
function _classPrivateFieldGet(s, a) { return s.get(_assertClassBrand(s, a)); }
|
|
7
|
+
function _classPrivateFieldSet(s, a, r) { return s.set(_assertClassBrand(s, a), r), r; }
|
|
8
|
+
function _assertClassBrand(e, t, n) { if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n; throw new TypeError("Private element is not present on this object"); }
|
|
9
|
+
import { logger } from "../utils/logger/index.js";
|
|
10
|
+
import { Future } from "../utils/future.js";
|
|
11
|
+
import { types } from "../types/proto.js";
|
|
12
|
+
import { TooManyConnectionsError, PermissionDeniedError, InvalidArgumentError, SessionTimeoutError, InternalError, GenericError } from "../types/exceptions.js";
|
|
13
|
+
const ErrorCode = types.Code;
|
|
14
|
+
export const ConnectionStatus = {
|
|
15
|
+
CONNECTED: "CONNECTED",
|
|
16
|
+
DISCONNECTED: "DISCONNECTED",
|
|
17
|
+
CONNECTING: "CONNECTING"
|
|
18
|
+
};
|
|
19
|
+
var _connectionStatus = /*#__PURE__*/new WeakMap();
|
|
20
|
+
var _connectionFuture = /*#__PURE__*/new WeakMap();
|
|
21
|
+
var _socket = /*#__PURE__*/new WeakMap();
|
|
22
|
+
export class ConnectionBase {
|
|
23
|
+
constructor(name) {
|
|
24
|
+
_classPrivateFieldInitSpec(this, _connectionStatus, void 0);
|
|
25
|
+
_classPrivateFieldInitSpec(this, _connectionFuture, void 0);
|
|
26
|
+
_classPrivateFieldInitSpec(this, _socket, void 0);
|
|
27
|
+
this.name = name;
|
|
28
|
+
_classPrivateFieldSet(_connectionStatus, this, ConnectionStatus.DISCONNECTED);
|
|
29
|
+
_classPrivateFieldSet(_connectionFuture, this, new Future());
|
|
30
|
+
_classPrivateFieldGet(_connectionFuture, this).reject("disconnected");
|
|
31
|
+
_classPrivateFieldSet(_socket, this, null);
|
|
32
|
+
}
|
|
33
|
+
async connect() {
|
|
34
|
+
if (_classPrivateFieldGet(_socket, this) != null) return;
|
|
35
|
+
logger.info("".concat(this.name, ": connecting ..."));
|
|
36
|
+
_classPrivateFieldSet(_connectionStatus, this, ConnectionStatus.CONNECTING);
|
|
37
|
+
_classPrivateFieldSet(_connectionFuture, this, new Future());
|
|
38
|
+
let uri = await this.getURI();
|
|
39
|
+
_classPrivateFieldSet(_socket, this, new WebSocket(uri));
|
|
40
|
+
_classPrivateFieldGet(_socket, this).binaryType = "arraybuffer";
|
|
41
|
+
_classPrivateFieldGet(_socket, this).addEventListener("open", () => {
|
|
42
|
+
this.onConnected();
|
|
43
|
+
});
|
|
44
|
+
_classPrivateFieldGet(_socket, this).addEventListener("close", () => {
|
|
45
|
+
this.onDisconnected();
|
|
46
|
+
});
|
|
47
|
+
_classPrivateFieldGet(_socket, this).addEventListener("message", event => {
|
|
48
|
+
this.onData(event.data);
|
|
49
|
+
});
|
|
50
|
+
_classPrivateFieldGet(_socket, this).addEventListener("error", err => {
|
|
51
|
+
this.onError(err);
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
async getURI() {
|
|
55
|
+
throw new Error("connection.getURI is not implemented");
|
|
56
|
+
}
|
|
57
|
+
disconnect() {
|
|
58
|
+
if (_classPrivateFieldGet(_socket, this) != null) {
|
|
59
|
+
_classPrivateFieldGet(_socket, this).close();
|
|
60
|
+
_classPrivateFieldSet(_socket, this, null);
|
|
61
|
+
logger.info("connection disconnected: ", this.name);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
async write(data) {
|
|
65
|
+
var _classPrivateFieldGet2, _classPrivateFieldGet3;
|
|
66
|
+
await this.waitForConnection();
|
|
67
|
+
(_classPrivateFieldGet2 = _classPrivateFieldGet(_socket, this)) === null || _classPrivateFieldGet2 === void 0 || (_classPrivateFieldGet3 = _classPrivateFieldGet2.send) === null || _classPrivateFieldGet3 === void 0 || _classPrivateFieldGet3.call(_classPrivateFieldGet2, data);
|
|
68
|
+
}
|
|
69
|
+
parseJSONResponse(msg) {
|
|
70
|
+
try {
|
|
71
|
+
let {
|
|
72
|
+
code,
|
|
73
|
+
reason
|
|
74
|
+
} = JSON.parse(msg);
|
|
75
|
+
switch (code) {
|
|
76
|
+
case ErrorCode.ERR_TOO_MANY_CONNECTIONS:
|
|
77
|
+
return this.onError(new TooManyConnectionsError(reason));
|
|
78
|
+
case ErrorCode.ERR_UNAUTHORIZED:
|
|
79
|
+
return this.onError(new PermissionDeniedError(reason));
|
|
80
|
+
case ErrorCode.ERR_BAD_REQUEST:
|
|
81
|
+
this.stop();
|
|
82
|
+
return this.onError(new InvalidArgumentError(reason));
|
|
83
|
+
case ErrorCode.ERR_TIMEOUT:
|
|
84
|
+
return this.onError(new SessionTimeoutError(reason));
|
|
85
|
+
case ErrorCode.ERR_INTERNAL:
|
|
86
|
+
return this.onError(new InternalError(code, reason));
|
|
87
|
+
default:
|
|
88
|
+
return this.onError(new GenericError(code, reason));
|
|
89
|
+
}
|
|
90
|
+
} catch (e) {
|
|
91
|
+
this.onError(e);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
getBufferedAmount() {
|
|
95
|
+
return _classPrivateFieldGet(_socket, this) ? _classPrivateFieldGet(_socket, this).bufferedAmount : 0;
|
|
96
|
+
}
|
|
97
|
+
onConnected() {
|
|
98
|
+
logger.info("".concat(this.name, ": connected"));
|
|
99
|
+
_classPrivateFieldSet(_connectionStatus, this, ConnectionStatus.CONNECTED);
|
|
100
|
+
_classPrivateFieldGet(_connectionFuture, this).set("connected");
|
|
101
|
+
}
|
|
102
|
+
onDisconnected() {
|
|
103
|
+
if (_classPrivateFieldGet(_socket, this) != null) {
|
|
104
|
+
_classPrivateFieldGet(_socket, this).close();
|
|
105
|
+
_classPrivateFieldSet(_socket, this, null);
|
|
106
|
+
logger.info("connection disconnected: ", this.name);
|
|
107
|
+
}
|
|
108
|
+
logger.warn("".concat(this.name, ": disconnected"));
|
|
109
|
+
_classPrivateFieldSet(_connectionStatus, this, ConnectionStatus.DISCONNECTED);
|
|
110
|
+
_classPrivateFieldGet(_connectionFuture, this).reject("disconnected");
|
|
111
|
+
}
|
|
112
|
+
isConnected() {
|
|
113
|
+
return _classPrivateFieldGet(_connectionStatus, this) == ConnectionStatus.CONNECTED;
|
|
114
|
+
}
|
|
115
|
+
waitForConnection() {
|
|
116
|
+
return _classPrivateFieldGet(_connectionFuture, this).get();
|
|
117
|
+
}
|
|
118
|
+
getConnectionStatus() {
|
|
119
|
+
return _classPrivateFieldGet(_connectionStatus, this);
|
|
120
|
+
}
|
|
121
|
+
onData(_data) {}
|
|
122
|
+
onError(err) {
|
|
123
|
+
logger.warn("".concat(this.name, ": onError: ").concat(err));
|
|
124
|
+
}
|
|
125
|
+
}
|