@vonage/client-sdk 0.1.4-alpha.3 → 0.1.4-alpha.5
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/dist/Client.d.ts +24 -25
- package/dist/HttpClient.d.ts +8 -8
- package/dist/MediaClient.d.ts +19 -19
- package/dist/SocketClient.d.ts +12 -12
- package/dist/coreExtend.d.ts +13 -13
- package/dist/global.d.ts +7 -7
- package/dist/index.cjs.js +45493 -0
- package/dist/index.d.ts +4 -3
- package/dist/index.js +45468 -11
- package/dist/utils/createRtcAudioConnection.d.ts +5 -5
- package/dist/vonageClientSDK.esm.js +56181 -0
- package/dist/vonageClientSDK.esm.min.js +2 -0
- package/dist/vonageClientSDK.js +56193 -0
- package/dist/vonageClientSDK.min.js +2 -0
- package/package.json +19 -7
- package/rollup.config.js +94 -0
- package/dist/Client.js +0 -40
- package/dist/HttpClient.js +0 -59
- package/dist/MediaClient.js +0 -130
- package/dist/SocketClient.js +0 -79
- package/dist/coreExtend.js +0 -3
- package/dist/global.js +0 -2
- package/dist/kotlin/Kermit-kermit-js-ir.js +0 -300
- package/dist/kotlin/Kermit-kermit-js-ir.js.map +0 -1
- package/dist/kotlin/clientsdk-clientcore.js +0 -22413
- package/dist/kotlin/clientsdk-clientcore.js.map +0 -1
- package/dist/kotlin/clientsdk-clientcore_js.js +0 -1403
- package/dist/kotlin/clientsdk-clientcore_js.js.map +0 -1
- package/dist/kotlin/kotlin-kotlin-stdlib-js-ir.js +0 -11107
- package/dist/kotlin/kotlin-kotlin-stdlib-js-ir.js.map +0 -1
- package/dist/kotlin/kotlinx-serialization-kotlinx-serialization-core-js-ir.js +0 -5857
- package/dist/kotlin/kotlinx-serialization-kotlinx-serialization-core-js-ir.js.map +0 -1
- package/dist/kotlin/kotlinx-serialization-kotlinx-serialization-json-js-ir.js +0 -5341
- package/dist/kotlin/kotlinx-serialization-kotlinx-serialization-json-js-ir.js.map +0 -1
- package/dist/utils/createRtcAudioConnection.js +0 -85
package/package.json
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vonage/client-sdk",
|
|
3
|
-
"version": "0.1.4-alpha.
|
|
3
|
+
"version": "0.1.4-alpha.5",
|
|
4
4
|
"description": "",
|
|
5
|
-
"
|
|
6
|
-
"
|
|
5
|
+
"module": "dist/index.js",
|
|
6
|
+
"main": "dist/index.cjs.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"type": "module",
|
|
7
9
|
"scripts": {
|
|
8
10
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
9
11
|
"copy_core": "rm -rf src/kotlin; mkdir src/kotlin; cp ../build/js/packages/clientsdk-clientcore_js/kotlin/* ./src/kotlin/",
|
|
10
|
-
"copy_core_dist": "mkdir dist/kotlin; cp ./src/kotlin
|
|
11
|
-
"build": "npm run copy_core;
|
|
12
|
+
"copy_core_dist": "mkdir dist/kotlin; cp ./src/kotlin/**.d.ts ./dist/kotlin/",
|
|
13
|
+
"build": "npm run copy_core; rollup -c; npm run copy_core_dist",
|
|
14
|
+
"build:rollup": "rollup -c",
|
|
12
15
|
"start": "node dist/Client.js",
|
|
13
16
|
"build:watch": "tsc -w",
|
|
14
17
|
"check": "tsc ./examples/* --noEmit --skipLibCheck --strictNullChecks true",
|
|
@@ -30,6 +33,11 @@
|
|
|
30
33
|
"webRTC"
|
|
31
34
|
],
|
|
32
35
|
"devDependencies": {
|
|
36
|
+
"@rollup/plugin-commonjs": "^24.0.0",
|
|
37
|
+
"@rollup/plugin-json": "^6.0.0",
|
|
38
|
+
"@rollup/plugin-node-resolve": "^15.0.1",
|
|
39
|
+
"@rollup/plugin-terser": "^0.2.1",
|
|
40
|
+
"@swc/core": "^1.3.24",
|
|
33
41
|
"@types/sdp-transform": "^2.4.5",
|
|
34
42
|
"@types/socket.io-client": "^1.4.32",
|
|
35
43
|
"@types/util.promisify": "^1.0.4",
|
|
@@ -39,10 +47,14 @@
|
|
|
39
47
|
"eslint-config-prettier": "^8.3.0",
|
|
40
48
|
"eslint-plugin-prettier": "^4.0.0",
|
|
41
49
|
"prettier": "^2.5.1",
|
|
42
|
-
"
|
|
50
|
+
"rollup": "^3.9.0",
|
|
51
|
+
"rollup-plugin-swc3": "^0.8.0",
|
|
52
|
+
"rollup-plugin-typescript2": "^0.34.1",
|
|
53
|
+
"tslib": "^2.4.1",
|
|
54
|
+
"typescript": "^4.9.4"
|
|
43
55
|
},
|
|
44
56
|
"dependencies": {
|
|
45
|
-
"axios": "^
|
|
57
|
+
"axios": "^1.2.2",
|
|
46
58
|
"events": "^3.3.0",
|
|
47
59
|
"sdp-transform": "^2.14.1",
|
|
48
60
|
"socket.io-client": "^2.4.0",
|
package/rollup.config.js
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { nodeResolve } from '@rollup/plugin-node-resolve';
|
|
2
|
+
import commonjs from '@rollup/plugin-commonjs';
|
|
3
|
+
import json from '@rollup/plugin-json';
|
|
4
|
+
import typescript from 'rollup-plugin-typescript2';
|
|
5
|
+
import terser from '@rollup/plugin-terser';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @type {import('rollup').RollupOptions}
|
|
9
|
+
*/
|
|
10
|
+
const browserBundles = [
|
|
11
|
+
{
|
|
12
|
+
input: 'src/index.ts',
|
|
13
|
+
output: [
|
|
14
|
+
{
|
|
15
|
+
name: 'vonageClientSDK',
|
|
16
|
+
file: 'dist/vonageClientSDK.js',
|
|
17
|
+
format: 'umd'
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
file: 'dist/vonageClientSDK.esm.js',
|
|
21
|
+
format: 'es'
|
|
22
|
+
}
|
|
23
|
+
],
|
|
24
|
+
treeshake: true,
|
|
25
|
+
plugins: [
|
|
26
|
+
json(),
|
|
27
|
+
nodeResolve({
|
|
28
|
+
jsnext: true,
|
|
29
|
+
preferBuiltins: false,
|
|
30
|
+
browser: true
|
|
31
|
+
}),
|
|
32
|
+
commonjs(),
|
|
33
|
+
typescript()
|
|
34
|
+
]
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
input: 'src/index.ts',
|
|
38
|
+
output: [
|
|
39
|
+
{
|
|
40
|
+
name: 'vonageClientSDK',
|
|
41
|
+
file: 'dist/vonageClientSDK.min.js',
|
|
42
|
+
format: 'umd'
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
file: 'dist/vonageClientSDK.esm.min.js',
|
|
46
|
+
format: 'es'
|
|
47
|
+
}
|
|
48
|
+
],
|
|
49
|
+
treeshake: true,
|
|
50
|
+
plugins: [
|
|
51
|
+
json(),
|
|
52
|
+
nodeResolve({
|
|
53
|
+
jsnext: true,
|
|
54
|
+
preferBuiltins: false,
|
|
55
|
+
browser: true
|
|
56
|
+
}),
|
|
57
|
+
commonjs(),
|
|
58
|
+
typescript(),
|
|
59
|
+
terser()
|
|
60
|
+
]
|
|
61
|
+
}
|
|
62
|
+
];
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* @type {import('rollup').RollupOptions}
|
|
66
|
+
*/
|
|
67
|
+
const npmBundles = [
|
|
68
|
+
{
|
|
69
|
+
input: 'src/index.ts',
|
|
70
|
+
external: ['axios', 'socket.io-client'],
|
|
71
|
+
output: [
|
|
72
|
+
{
|
|
73
|
+
file: './dist/index.js',
|
|
74
|
+
format: 'es'
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
file: './dist/index.cjs.js',
|
|
78
|
+
format: 'cjs'
|
|
79
|
+
}
|
|
80
|
+
],
|
|
81
|
+
treeshake: true,
|
|
82
|
+
plugins: [
|
|
83
|
+
json(),
|
|
84
|
+
nodeResolve({ preferBuiltins: false }),
|
|
85
|
+
commonjs(),
|
|
86
|
+
typescript()
|
|
87
|
+
]
|
|
88
|
+
}
|
|
89
|
+
];
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* @type {import('rollup').RollupOptions}
|
|
93
|
+
*/
|
|
94
|
+
export default [...browserBundles, ...npmBundles];
|
package/dist/Client.js
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ClientConfig = exports.setDefaultLoggingLevel = exports.LoggingLevel = exports.ConfigRegion = void 0;
|
|
4
|
-
const clientsdk_clientcore_js_1 = require("./kotlin/clientsdk-clientcore_js");
|
|
5
|
-
require("./coreExtend");
|
|
6
|
-
const HttpClient_1 = require("./HttpClient");
|
|
7
|
-
const MediaClient_1 = require("./MediaClient");
|
|
8
|
-
const SocketClient_1 = require("./SocketClient");
|
|
9
|
-
require("./global");
|
|
10
|
-
exports.ConfigRegion = clientsdk_clientcore_js_1.vonage.CoreClientConfigRegionJS;
|
|
11
|
-
exports.LoggingLevel = clientsdk_clientcore_js_1.vonage.LoggingLevelJS;
|
|
12
|
-
exports.setDefaultLoggingLevel = clientsdk_clientcore_js_1.vonage.setDefaultLoggingLevel;
|
|
13
|
-
class ClientConfig extends clientsdk_clientcore_js_1.vonage.CoreClientConfigJS {
|
|
14
|
-
constructor(region = exports.ConfigRegion.US) {
|
|
15
|
-
super(region);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
exports.ClientConfig = ClientConfig;
|
|
19
|
-
class VoiceClient extends clientsdk_clientcore_js_1.vonage.CoreClientJS {
|
|
20
|
-
constructor() {
|
|
21
|
-
super(new HttpClient_1.default(), new SocketClient_1.default(), new MediaClient_1.default());
|
|
22
|
-
this.callbacks = new Map();
|
|
23
|
-
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
24
|
-
const _this = this;
|
|
25
|
-
this.emitter = new Proxy(Object(), {
|
|
26
|
-
get(_, prop) {
|
|
27
|
-
// NOTE: with great power comes great responsiblity ...
|
|
28
|
-
// We skip ts checks here, but enforce safety via on() generic type constraints.
|
|
29
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
30
|
-
// @ts-ignore
|
|
31
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
32
|
-
return _this.callbacks.get(prop) || (() => { });
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
on(event, callback) {
|
|
37
|
-
this.callbacks.set(event, callback);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
exports.default = VoiceClient;
|
package/dist/HttpClient.js
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
const axios_1 = require("axios");
|
|
13
|
-
class HttpClient {
|
|
14
|
-
stringToVerb(m) {
|
|
15
|
-
if (m.toLowerCase() === 'get')
|
|
16
|
-
return 'GET';
|
|
17
|
-
else if (m.toLowerCase() === 'post')
|
|
18
|
-
return 'POST';
|
|
19
|
-
else if (m.toLowerCase() === 'patch')
|
|
20
|
-
return 'PATCH';
|
|
21
|
-
else if (m.toLowerCase() === 'put')
|
|
22
|
-
return 'PUT';
|
|
23
|
-
else if (m.toLowerCase() === 'options')
|
|
24
|
-
return 'OPTIONS';
|
|
25
|
-
else if (m.toLowerCase() === 'delete')
|
|
26
|
-
return 'DELETE';
|
|
27
|
-
else
|
|
28
|
-
return 'GET';
|
|
29
|
-
}
|
|
30
|
-
request(verb, url, headers, body, callback) {
|
|
31
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
32
|
-
const method = this.stringToVerb(verb);
|
|
33
|
-
const data = body !== null && body.length > 0 ? JSON.parse(body) : '';
|
|
34
|
-
const axiosReq = {
|
|
35
|
-
url,
|
|
36
|
-
method,
|
|
37
|
-
headers,
|
|
38
|
-
data
|
|
39
|
-
};
|
|
40
|
-
try {
|
|
41
|
-
const res = yield (0, axios_1.default)(axiosReq);
|
|
42
|
-
console.log(`[JS response]: `, res.data);
|
|
43
|
-
callback(null, JSON.stringify(res.data));
|
|
44
|
-
}
|
|
45
|
-
catch (error) {
|
|
46
|
-
// let errorMessage: string = '';
|
|
47
|
-
// let errorStack: string = '';
|
|
48
|
-
let e = Error('');
|
|
49
|
-
if (error instanceof Error) {
|
|
50
|
-
// errorMessage = error.message;
|
|
51
|
-
// errorStack = error.stack;
|
|
52
|
-
e = error;
|
|
53
|
-
}
|
|
54
|
-
callback(e, null);
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
exports.default = HttpClient;
|
package/dist/MediaClient.js
DELETED
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
const createRtcAudioConnection_1 = require("./utils/createRtcAudioConnection");
|
|
13
|
-
class MediaClient {
|
|
14
|
-
constructor() {
|
|
15
|
-
this.pcs = new Map();
|
|
16
|
-
this.audio = undefined;
|
|
17
|
-
}
|
|
18
|
-
enableMediaInbound(closure, offerSDP, rtcId) {
|
|
19
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
-
let sdp;
|
|
21
|
-
let error;
|
|
22
|
-
try {
|
|
23
|
-
const pc = yield this.getNewPC();
|
|
24
|
-
this.pcs.set(rtcId, pc);
|
|
25
|
-
sdp = yield (0, createRtcAudioConnection_1.createAnswer)(pc, offerSDP);
|
|
26
|
-
}
|
|
27
|
-
catch (err) {
|
|
28
|
-
error = err;
|
|
29
|
-
}
|
|
30
|
-
finally {
|
|
31
|
-
closure(error, sdp);
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
enableMediaOutbound(closure) {
|
|
36
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
37
|
-
let error;
|
|
38
|
-
let pc;
|
|
39
|
-
let sdp;
|
|
40
|
-
try {
|
|
41
|
-
pc = yield this.getNewPC();
|
|
42
|
-
sdp = yield (0, createRtcAudioConnection_1.createOffer)(pc);
|
|
43
|
-
}
|
|
44
|
-
catch (err) {
|
|
45
|
-
error = err;
|
|
46
|
-
}
|
|
47
|
-
finally {
|
|
48
|
-
closure(error, sdp, (legId) => {
|
|
49
|
-
this.pcs.set(legId, pc);
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
getNewPC() {
|
|
55
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
56
|
-
const pc = yield (0, createRtcAudioConnection_1.createRtcAudioConnection)();
|
|
57
|
-
pc.ontrack = (evt) => {
|
|
58
|
-
const stream = evt.streams[0];
|
|
59
|
-
if (stream) {
|
|
60
|
-
const audio = new Audio();
|
|
61
|
-
audio.srcObject = stream;
|
|
62
|
-
audio.autoplay = true;
|
|
63
|
-
this.audio = audio;
|
|
64
|
-
this.stream = stream;
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
return pc;
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
mute(id) {
|
|
71
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
72
|
-
this.setMediaTracksEnabled(id, false);
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
unmute(id) {
|
|
76
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
77
|
-
this.setMediaTracksEnabled(id, true);
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
getPeerConnection(id) {
|
|
81
|
-
const pc = this.pcs.get(id);
|
|
82
|
-
return pc;
|
|
83
|
-
}
|
|
84
|
-
// async getLocalStream(): Promise<MediaStream> {
|
|
85
|
-
// return await navigator.mediaDevices.getUserMedia({
|
|
86
|
-
// video: false,
|
|
87
|
-
// audio: true
|
|
88
|
-
// });
|
|
89
|
-
// }
|
|
90
|
-
processAnswer(id, sdp) {
|
|
91
|
-
const remoteDescription = new RTCSessionDescription({
|
|
92
|
-
type: 'answer',
|
|
93
|
-
sdp
|
|
94
|
-
});
|
|
95
|
-
const pc = this.pcs.get(id);
|
|
96
|
-
if (pc) {
|
|
97
|
-
pc.setRemoteDescription(remoteDescription);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
disableMedia(id) {
|
|
101
|
-
const peerConnection = this.pcs.get(id);
|
|
102
|
-
if (peerConnection) {
|
|
103
|
-
peerConnection.close();
|
|
104
|
-
this.pcs.delete(id);
|
|
105
|
-
peerConnection.getSenders().forEach((sender) => {
|
|
106
|
-
var _a;
|
|
107
|
-
(_a = sender.track) === null || _a === void 0 ? void 0 : _a.stop();
|
|
108
|
-
});
|
|
109
|
-
peerConnection.getReceivers().forEach((receiver) => {
|
|
110
|
-
var _a;
|
|
111
|
-
(_a = receiver.track) === null || _a === void 0 ? void 0 : _a.stop();
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
else {
|
|
115
|
-
throw new Error('No RTCPeerConnection established');
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
// Private Methods
|
|
119
|
-
setMediaTracksEnabled(id, value) {
|
|
120
|
-
const pc = this.pcs.get(id);
|
|
121
|
-
const transceiver = pc === null || pc === void 0 ? void 0 : pc.getTransceivers();
|
|
122
|
-
const tracks = transceiver === null || transceiver === void 0 ? void 0 : transceiver.map((t) => t.sender.track);
|
|
123
|
-
tracks === null || tracks === void 0 ? void 0 : tracks.forEach((t) => {
|
|
124
|
-
if (t) {
|
|
125
|
-
t.enabled = value;
|
|
126
|
-
}
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
exports.default = MediaClient;
|
package/dist/SocketClient.js
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const clientsdk_clientcore_js_1 = require("./kotlin/clientsdk-clientcore_js");
|
|
4
|
-
const socket_io = require("socket.io-client");
|
|
5
|
-
// import { SocketConfig } from './NexmoClient';
|
|
6
|
-
class SocketClient {
|
|
7
|
-
emit(type, msg, _callback) {
|
|
8
|
-
var _a;
|
|
9
|
-
(_a = this.socket) === null || _a === void 0 ? void 0 : _a.emit(type, msg);
|
|
10
|
-
_callback(null, ''); // WHAT DO I NEED TODO HERE?
|
|
11
|
-
}
|
|
12
|
-
connect(host, path, reconnectionAttempts, reconnectionDelay, randomizationFactor, query) {
|
|
13
|
-
const config = {
|
|
14
|
-
transports: ['websocket'],
|
|
15
|
-
autoConnect: true,
|
|
16
|
-
reconnection: true,
|
|
17
|
-
forceNew: true,
|
|
18
|
-
path,
|
|
19
|
-
reconnectionAttempts,
|
|
20
|
-
reconnectionDelay,
|
|
21
|
-
randomizationFactor,
|
|
22
|
-
query
|
|
23
|
-
};
|
|
24
|
-
this.socket = socket_io.connect(host, config);
|
|
25
|
-
this.socket.on('connect', () => {
|
|
26
|
-
var _a;
|
|
27
|
-
(_a = this.delegate) === null || _a === void 0 ? void 0 : _a.didReceiveNewSocketConnectionStatusEvent(clientsdk_clientcore_js_1.vonage.SOCKET_CONNECTED, null);
|
|
28
|
-
});
|
|
29
|
-
this.socket.on('reconnect_attempt', () => {
|
|
30
|
-
var _a;
|
|
31
|
-
(_a = this.delegate) === null || _a === void 0 ? void 0 : _a.didReceiveNewSocketConnectionStatusEvent(clientsdk_clientcore_js_1.vonage.SOCKET_RECONNECTING, null);
|
|
32
|
-
});
|
|
33
|
-
this.socket.on('reconnect_failed', () => {
|
|
34
|
-
var _a;
|
|
35
|
-
(_a = this.delegate) === null || _a === void 0 ? void 0 : _a.didReceiveNewSocketConnectionStatusEvent(clientsdk_clientcore_js_1.vonage.SOCKET_DISCONNECTED, clientsdk_clientcore_js_1.vonage.REASON_CLIENT_NETWORK_ERROR);
|
|
36
|
-
});
|
|
37
|
-
this.socket.on('disconnect', (reason) => {
|
|
38
|
-
var _a, _b;
|
|
39
|
-
console.log({ reason });
|
|
40
|
-
if (reason === 'io client disconnect') {
|
|
41
|
-
(_a = this.delegate) === null || _a === void 0 ? void 0 : _a.didReceiveNewSocketConnectionStatusEvent(clientsdk_clientcore_js_1.vonage.SOCKET_DISCONNECTED, clientsdk_clientcore_js_1.vonage.REASON_CLIENT_DISCONNECTED);
|
|
42
|
-
}
|
|
43
|
-
else if (reason === 'io server disconnect') {
|
|
44
|
-
(_b = this.delegate) === null || _b === void 0 ? void 0 : _b.didReceiveNewSocketConnectionStatusEvent(clientsdk_clientcore_js_1.vonage.SOCKET_DISCONNECTED, clientsdk_clientcore_js_1.vonage.REASON_SERVER_DISCONNECTED);
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
this.socket.io.on('packet', (packet) => {
|
|
48
|
-
var _a;
|
|
49
|
-
if (packet.type !== 2)
|
|
50
|
-
return;
|
|
51
|
-
if (packet.data[0] === 'echo')
|
|
52
|
-
return; // ignore echo event
|
|
53
|
-
const [type, body] = packet.data;
|
|
54
|
-
if (typeof type == 'string' && body instanceof Object) {
|
|
55
|
-
(_a = this.delegate) === null || _a === void 0 ? void 0 : _a.didReceiveNewSocketEvent(type, JSON.stringify(body));
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
disconnect() {
|
|
60
|
-
var _a;
|
|
61
|
-
(_a = this.socket) === null || _a === void 0 ? void 0 : _a.disconnect();
|
|
62
|
-
}
|
|
63
|
-
startVerifyResponseTimer(milliseconds, callback) {
|
|
64
|
-
// console.log(`startVerifyResponseTimer: ${milliseconds}`);
|
|
65
|
-
setTimeout(() => {
|
|
66
|
-
callback();
|
|
67
|
-
}, milliseconds);
|
|
68
|
-
}
|
|
69
|
-
setConnectParamsSocketConfig(
|
|
70
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
71
|
-
token) {
|
|
72
|
-
if (this.socket) {
|
|
73
|
-
this.socket.io.opts.query = {
|
|
74
|
-
token: token
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
exports.default = SocketClient;
|
package/dist/coreExtend.js
DELETED
package/dist/global.js
DELETED