@flashphoner/sfusdk 1.0.41 → 2.0.48
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/examples/sfu.d.ts +13 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +15 -0
- package/dist/index.js.map +1 -0
- package/dist/sdk/connection.d.ts +25 -0
- package/dist/sdk/connection.js +101 -0
- package/dist/sdk/connection.js.map +1 -0
- package/dist/sdk/constants.d.ts +355 -0
- package/dist/sdk/constants.js +190 -0
- package/dist/sdk/constants.js.map +1 -0
- package/dist/sdk/logger.d.ts +10 -0
- package/dist/sdk/logger.js +22 -0
- package/dist/sdk/logger.js.map +1 -0
- package/dist/sdk/notifier.d.ts +7 -0
- package/dist/sdk/notifier.js +52 -0
- package/dist/sdk/notifier.js.map +1 -0
- package/dist/sdk/promises.d.ts +11 -0
- package/{src/sdk/promise.js → dist/sdk/promises.js} +14 -13
- package/dist/sdk/promises.js.map +1 -0
- package/dist/sdk/room-extended.d.ts +13 -0
- package/dist/sdk/room-extended.js +112 -0
- package/dist/sdk/room-extended.js.map +1 -0
- package/dist/sdk/room.d.ts +30 -0
- package/dist/sdk/room.js +384 -0
- package/dist/sdk/room.js.map +1 -0
- package/dist/sdk/sfu-extended.d.ts +126 -0
- package/dist/sdk/sfu-extended.js +511 -0
- package/dist/sdk/sfu-extended.js.map +1 -0
- package/dist/sdk/sfu.d.ts +22 -0
- package/dist/sdk/sfu.js +136 -0
- package/dist/sdk/sfu.js.map +1 -0
- package/dist/src/index.d.ts +6 -0
- package/dist/src/sdk/connection.d.ts +25 -0
- package/dist/src/sdk/constants.d.ts +355 -0
- package/dist/src/sdk/logger.d.ts +10 -0
- package/dist/src/sdk/notifier.d.ts +7 -0
- package/dist/src/sdk/promises.d.ts +11 -0
- package/dist/src/sdk/room-extended.d.ts +13 -0
- package/dist/src/sdk/room.d.ts +30 -0
- package/dist/src/sdk/sfu-extended.d.ts +126 -0
- package/dist/src/sdk/sfu.d.ts +22 -0
- package/package.json +27 -24
- package/Gruntfile.js +0 -79
- package/README.md +0 -95
- package/dependencies/bootstrap/css/bootstrap-theme.css +0 -587
- package/dependencies/bootstrap/css/bootstrap-theme.css.map +0 -1
- package/dependencies/bootstrap/css/bootstrap-theme.min.css +0 -5
- package/dependencies/bootstrap/css/bootstrap.css +0 -6853
- package/dependencies/bootstrap/css/bootstrap.css.map +0 -1
- package/dependencies/bootstrap/css/bootstrap.min.css +0 -5
- package/dependencies/bootstrap/font-awesome/HELP-US-OUT.txt +0 -7
- package/dependencies/bootstrap/font-awesome/css/font-awesome.css +0 -2178
- package/dependencies/bootstrap/font-awesome/css/font-awesome.min.css +0 -4
- package/dependencies/bootstrap/font-awesome/fonts/FontAwesome.otf +0 -0
- package/dependencies/bootstrap/font-awesome/fonts/fontawesome-webfont.eot +0 -0
- package/dependencies/bootstrap/font-awesome/fonts/fontawesome-webfont.svg +0 -685
- package/dependencies/bootstrap/font-awesome/fonts/fontawesome-webfont.ttf +0 -0
- package/dependencies/bootstrap/font-awesome/fonts/fontawesome-webfont.woff +0 -0
- package/dependencies/bootstrap/font-awesome/fonts/fontawesome-webfont.woff2 +0 -0
- package/dependencies/bootstrap/font-awesome/less/animated.less +0 -34
- package/dependencies/bootstrap/font-awesome/less/bordered-pulled.less +0 -25
- package/dependencies/bootstrap/font-awesome/less/core.less +0 -12
- package/dependencies/bootstrap/font-awesome/less/fixed-width.less +0 -6
- package/dependencies/bootstrap/font-awesome/less/font-awesome.less +0 -18
- package/dependencies/bootstrap/font-awesome/less/icons.less +0 -724
- package/dependencies/bootstrap/font-awesome/less/larger.less +0 -13
- package/dependencies/bootstrap/font-awesome/less/list.less +0 -19
- package/dependencies/bootstrap/font-awesome/less/mixins.less +0 -60
- package/dependencies/bootstrap/font-awesome/less/path.less +0 -15
- package/dependencies/bootstrap/font-awesome/less/rotated-flipped.less +0 -20
- package/dependencies/bootstrap/font-awesome/less/screen-reader.less +0 -5
- package/dependencies/bootstrap/font-awesome/less/stacked.less +0 -20
- package/dependencies/bootstrap/font-awesome/less/variables.less +0 -735
- package/dependencies/bootstrap/font-awesome/scss/_animated.scss +0 -34
- package/dependencies/bootstrap/font-awesome/scss/_bordered-pulled.scss +0 -25
- package/dependencies/bootstrap/font-awesome/scss/_core.scss +0 -12
- package/dependencies/bootstrap/font-awesome/scss/_fixed-width.scss +0 -6
- package/dependencies/bootstrap/font-awesome/scss/_icons.scss +0 -724
- package/dependencies/bootstrap/font-awesome/scss/_larger.scss +0 -13
- package/dependencies/bootstrap/font-awesome/scss/_list.scss +0 -19
- package/dependencies/bootstrap/font-awesome/scss/_mixins.scss +0 -60
- package/dependencies/bootstrap/font-awesome/scss/_path.scss +0 -15
- package/dependencies/bootstrap/font-awesome/scss/_rotated-flipped.scss +0 -20
- package/dependencies/bootstrap/font-awesome/scss/_screen-reader.scss +0 -5
- package/dependencies/bootstrap/font-awesome/scss/_stacked.scss +0 -20
- package/dependencies/bootstrap/font-awesome/scss/_variables.scss +0 -735
- package/dependencies/bootstrap/font-awesome/scss/font-awesome.scss +0 -18
- package/dependencies/bootstrap/fonts/FontAwesome.otf +0 -0
- package/dependencies/bootstrap/fonts/fontawesome-webfont.eot +0 -0
- package/dependencies/bootstrap/fonts/fontawesome-webfont.svg +0 -655
- package/dependencies/bootstrap/fonts/fontawesome-webfont.ttf +0 -0
- package/dependencies/bootstrap/fonts/fontawesome-webfont.woff +0 -0
- package/dependencies/bootstrap/fonts/fontawesome-webfont.woff2 +0 -0
- package/dependencies/bootstrap/fonts/glyphicons-halflings-regular.eot +0 -0
- package/dependencies/bootstrap/fonts/glyphicons-halflings-regular.svg +0 -288
- package/dependencies/bootstrap/fonts/glyphicons-halflings-regular.ttf +0 -0
- package/dependencies/bootstrap/fonts/glyphicons-halflings-regular.woff +0 -0
- package/dependencies/bootstrap/fonts/glyphicons-halflings-regular.woff2 +0 -0
- package/dependencies/bootstrap/icons/font-awesome.min.css +0 -4
- package/dependencies/bootstrap/js/bootstrap.js +0 -2363
- package/dependencies/bootstrap/js/bootstrap.min.js +0 -7
- package/dependencies/bootstrap/js/npm.js +0 -13
- package/dependencies/bootstrap/js/switch.js +0 -85
- package/dependencies/jquery/jquery-1.12.0.js +0 -11027
- package/dependencies/jquery/jquery-ui.js +0 -16617
- package/dependencies/jquery/jquery.js +0 -8981
- package/dependencies/jquery/jquery.json.js +0 -199
- package/dependencies/jquery/jquery.websocket.js +0 -61
- package/dependencies/sigma/sigma.layout.forceAtlas2.min.js +0 -1
- package/dependencies/sigma/sigma.layout.noverlap.min.js +0 -1
- package/dependencies/sigma/sigma.min.js +0 -2
- package/dependencies/sigma/sigma.plugins.relativeSize.min.js +0 -1
- package/dependencies/sigma/sigma.renderers.edgeLabels.min.js +0 -1
- package/dependencies/sigma/sigma.renderers.parallelEdges.min.js +0 -1
- package/dependencies/sigma/sigma.require.js +0 -12076
- package/docTemplate/README.md +0 -5
- package/docTemplate/publish.js +0 -654
- package/docTemplate/static/fonts/OpenSans-Bold-webfont.eot +0 -0
- package/docTemplate/static/fonts/OpenSans-Bold-webfont.svg +0 -1830
- package/docTemplate/static/fonts/OpenSans-Bold-webfont.woff +0 -0
- package/docTemplate/static/fonts/OpenSans-BoldItalic-webfont.eot +0 -0
- package/docTemplate/static/fonts/OpenSans-BoldItalic-webfont.svg +0 -1830
- package/docTemplate/static/fonts/OpenSans-BoldItalic-webfont.woff +0 -0
- package/docTemplate/static/fonts/OpenSans-Italic-webfont.eot +0 -0
- package/docTemplate/static/fonts/OpenSans-Italic-webfont.svg +0 -1830
- package/docTemplate/static/fonts/OpenSans-Italic-webfont.woff +0 -0
- package/docTemplate/static/fonts/OpenSans-Light-webfont.eot +0 -0
- package/docTemplate/static/fonts/OpenSans-Light-webfont.svg +0 -1831
- package/docTemplate/static/fonts/OpenSans-Light-webfont.woff +0 -0
- package/docTemplate/static/fonts/OpenSans-LightItalic-webfont.eot +0 -0
- package/docTemplate/static/fonts/OpenSans-LightItalic-webfont.svg +0 -1835
- package/docTemplate/static/fonts/OpenSans-LightItalic-webfont.woff +0 -0
- package/docTemplate/static/fonts/OpenSans-Regular-webfont.eot +0 -0
- package/docTemplate/static/fonts/OpenSans-Regular-webfont.svg +0 -1831
- package/docTemplate/static/fonts/OpenSans-Regular-webfont.woff +0 -0
- package/docTemplate/static/scripts/linenumber.js +0 -25
- package/docTemplate/static/scripts/prettify/Apache-License-2.0.txt +0 -202
- package/docTemplate/static/scripts/prettify/lang-css.js +0 -2
- package/docTemplate/static/scripts/prettify/prettify.js +0 -28
- package/docTemplate/static/styles/jsdoc-default.css +0 -354
- package/docTemplate/static/styles/prettify-jsdoc.css +0 -111
- package/docTemplate/static/styles/prettify-tomorrow.css +0 -132
- package/docTemplate/tmpl/augments.tmpl +0 -10
- package/docTemplate/tmpl/container.tmpl +0 -183
- package/docTemplate/tmpl/details.tmpl +0 -143
- package/docTemplate/tmpl/example.tmpl +0 -2
- package/docTemplate/tmpl/examples.tmpl +0 -13
- package/docTemplate/tmpl/exceptions.tmpl +0 -32
- package/docTemplate/tmpl/layout.tmpl +0 -38
- package/docTemplate/tmpl/mainpage.tmpl +0 -14
- package/docTemplate/tmpl/members.tmpl +0 -38
- package/docTemplate/tmpl/method.tmpl +0 -105
- package/docTemplate/tmpl/params.tmpl +0 -124
- package/docTemplate/tmpl/properties.tmpl +0 -108
- package/docTemplate/tmpl/returns.tmpl +0 -19
- package/docTemplate/tmpl/source.tmpl +0 -8
- package/docTemplate/tmpl/tutorial.tmpl +0 -19
- package/docTemplate/tmpl/type.tmpl +0 -7
- package/src/examples/client/chat.js +0 -67
- package/src/examples/client/config.json +0 -26
- package/src/examples/client/controls.js +0 -314
- package/src/examples/client/display.js +0 -502
- package/src/examples/client/main.css +0 -45
- package/src/examples/client/main.html +0 -220
- package/src/examples/client/main.js +0 -156
- package/src/examples/client/resources/details_close.png +0 -0
- package/src/examples/client/resources/details_open.png +0 -0
- package/src/examples/client/util.js +0 -67
- package/src/examples/commons/js/config.js +0 -81
- package/src/examples/commons/js/display.js +0 -484
- package/src/examples/commons/js/util.js +0 -202
- package/src/examples/commons/media/silence.mp3 +0 -0
- package/src/examples/controller/dependencies/sigma/sigma.renderers.edgeLabels.min.js +0 -1
- package/src/examples/controller/dependencies/sigma/sigma.renderers.parallelEdges.min.js +0 -1
- package/src/examples/controller/dependencies/sigma/sigma.require.js +0 -12076
- package/src/examples/controller/graph-view.js +0 -32
- package/src/examples/controller/main.css +0 -45
- package/src/examples/controller/main.html +0 -79
- package/src/examples/controller/main.js +0 -65
- package/src/examples/controller/parser.js +0 -202
- package/src/examples/controller/resources/details_close.png +0 -0
- package/src/examples/controller/resources/details_open.png +0 -0
- package/src/examples/controller/rest.js +0 -56
- package/src/examples/controller/table-view.js +0 -64
- package/src/examples/controller/test-data.js +0 -382
- package/src/examples/player/config.json +0 -8
- package/src/examples/player/player.css +0 -19
- package/src/examples/player/player.html +0 -54
- package/src/examples/player/player.js +0 -209
- package/src/examples/two-way-streaming/config.json +0 -34
- package/src/examples/two-way-streaming/two-way-streaming.css +0 -26
- package/src/examples/two-way-streaming/two-way-streaming.html +0 -72
- package/src/examples/two-way-streaming/two-way-streaming.js +0 -375
- package/src/sdk/constants.js +0 -488
- package/src/sdk/messaging.js +0 -59
- package/src/sdk/room.js +0 -442
- package/src/sdk/sfu-extended.js +0 -513
- package/src/sdk/sfu.js +0 -179
- package/src/sdk/ws.js +0 -109
- package/src/tests/sdk/sfu-extended.test.js +0 -151
package/src/sdk/sfu-extended.js
DELETED
|
@@ -1,513 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @namespace FlashphonerSFUExtended
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const {v4: uuidv4} = require("uuid");
|
|
7
|
-
const ws = require("./ws");
|
|
8
|
-
const messaging = require("./messaging");
|
|
9
|
-
const roomApi = require("./room");
|
|
10
|
-
const promises = require("./promise");
|
|
11
|
-
const constants = require("./constants");
|
|
12
|
-
const SFU_STATE = constants.SFU_STATE;
|
|
13
|
-
const SFU_EVENT = constants.SFU_EVENT;
|
|
14
|
-
const SFU_INTERNAL = constants.SFU_INTERNAL_API;
|
|
15
|
-
const sfu = {};
|
|
16
|
-
let rooms = {};
|
|
17
|
-
let connection = ws.createConnection();
|
|
18
|
-
let server;
|
|
19
|
-
const callbacks = {};
|
|
20
|
-
|
|
21
|
-
let state = SFU_STATE.NEW;
|
|
22
|
-
let connectionConfig;
|
|
23
|
-
let user;
|
|
24
|
-
let im;
|
|
25
|
-
|
|
26
|
-
function setupConnection(connection) {
|
|
27
|
-
connection.onMessage = function(name, msg){
|
|
28
|
-
switch (name) {
|
|
29
|
-
case SFU_INTERNAL.DEFAULT_METHOD:
|
|
30
|
-
//filter messages
|
|
31
|
-
if (msg[0].type === SFU_INTERNAL.MESSAGE) {
|
|
32
|
-
notify(SFU_EVENT.MESSAGE, msg[0].message);
|
|
33
|
-
} else if (msg[0].type === SFU_INTERNAL.MESSAGE_STATE) {
|
|
34
|
-
im.onMessageState(msg);
|
|
35
|
-
notify(SFU_EVENT.MESSAGE_STATE, msg[0].status);
|
|
36
|
-
} else if (msg[0].type === SFU_INTERNAL.USER_LIST) {
|
|
37
|
-
promises.resolve(msg[0].internalMessageId, msg[0].list);
|
|
38
|
-
notify(SFU_EVENT.USER_LIST, msg[0].list);
|
|
39
|
-
} else if (msg[0].type === SFU_INTERNAL.USER_CALENDAR) {
|
|
40
|
-
promises.resolve(msg[0].internalMessageId, msg[0].calendar);
|
|
41
|
-
notify(SFU_EVENT.USER_CALENDAR, msg[0].calendar);
|
|
42
|
-
} else if (msg[0].type === SFU_INTERNAL.NEW_CHAT) {
|
|
43
|
-
if(!promises.resolve(msg[0].internalMessageId, msg[0].info)) {
|
|
44
|
-
notify(SFU_EVENT.NEW_CHAT, msg[0].info);
|
|
45
|
-
}
|
|
46
|
-
} else if (msg[0].type === SFU_INTERNAL.CHAT_DELETED) {
|
|
47
|
-
notify(SFU_EVENT.CHAT_DELETED, msg[0].info);
|
|
48
|
-
} else if (msg[0].type === SFU_INTERNAL.CHAT_UPDATED) {
|
|
49
|
-
promises.resolve(msg[0].internalMessageId, msg[0].info);
|
|
50
|
-
notify(SFU_EVENT.CHAT_UPDATED, msg[0].info);
|
|
51
|
-
} else if (msg[0].type === SFU_INTERNAL.USER_CHATS) {
|
|
52
|
-
promises.resolve(msg[0].internalMessageId, msg[0].chats);
|
|
53
|
-
notify(SFU_EVENT.USER_CHATS, msg[0].chats);
|
|
54
|
-
} else if (msg[0].type === SFU_INTERNAL.CHAT_LOADED) {
|
|
55
|
-
promises.resolve(msg[0].internalMessageId, msg[0].chat);
|
|
56
|
-
notify(SFU_EVENT.CHAT_LOADED, msg[0].chat);
|
|
57
|
-
} else if (msg[0].type === constants.SFU_ROOM_EVENT.OPERATION_FAILED && promises.promised(msg[0].internalMessageId)) {
|
|
58
|
-
promises.reject(msg[0].internalMessageId, msg[0]);
|
|
59
|
-
} else if (msg[0].type === constants.SFU_EVENT.ACK && promises.promised(msg[0].internalMessageId)) {
|
|
60
|
-
promises.resolve(msg[0].internalMessageId);
|
|
61
|
-
} else if (msg[0].roomName && msg[0].roomName.length > 0) {
|
|
62
|
-
//room event
|
|
63
|
-
const room = rooms[msg[0].roomName];
|
|
64
|
-
if (room) {
|
|
65
|
-
room.processEvent(msg[0]);
|
|
66
|
-
}
|
|
67
|
-
} else {
|
|
68
|
-
notify(msg[0].type, msg[0]);
|
|
69
|
-
}
|
|
70
|
-
break;
|
|
71
|
-
case "failed":
|
|
72
|
-
notify(constants.SFU_EVENT.FAILED, msg[0]);
|
|
73
|
-
break;
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
connection.onClose = function(e) {
|
|
78
|
-
state = SFU_STATE.DISCONNECTED;
|
|
79
|
-
disconnect();
|
|
80
|
-
notify(SFU_EVENT.DISCONNECTED, e);
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
connection.onError = function(e) {
|
|
84
|
-
state = SFU_STATE.FAILED;
|
|
85
|
-
notify(SFU_STATE.FAILED, e);
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
im = messaging.create({
|
|
89
|
-
connection: connection
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Connect to server.
|
|
94
|
-
*
|
|
95
|
-
* @param {Object} options SFU options
|
|
96
|
-
* @param {String} options.url Server url
|
|
97
|
-
* @param {String} options.username Username
|
|
98
|
-
* @param {String} options.password Password
|
|
99
|
-
* @param {String=} options.nickname Participant's nickname
|
|
100
|
-
* @returns {Promise<void|Error>} Promise which resolves upon connect
|
|
101
|
-
* @throws {TypeError} Error if no options provided
|
|
102
|
-
* @memberof FlashphonerSFUExtended
|
|
103
|
-
*/
|
|
104
|
-
const connect = function(options) {
|
|
105
|
-
if (!options) {
|
|
106
|
-
throw new TypeError("No options provided");
|
|
107
|
-
}
|
|
108
|
-
setupConnection(connection);
|
|
109
|
-
server = new URL(options.url).hostname;
|
|
110
|
-
connectionConfig = {
|
|
111
|
-
url: options.url,
|
|
112
|
-
appName: SFU_INTERNAL.Z_APP,
|
|
113
|
-
custom: {
|
|
114
|
-
username: options.username,
|
|
115
|
-
password: options.password,
|
|
116
|
-
nickname: options.nickname
|
|
117
|
-
}
|
|
118
|
-
};
|
|
119
|
-
return new Promise(function(resolve, reject) {
|
|
120
|
-
if (state !== SFU_STATE.NEW && state !== SFU_STATE.DISCONNECTED && state !== SFU_STATE.FAILED) {
|
|
121
|
-
reject(new Error("Can't connect with the state " + state));
|
|
122
|
-
return;
|
|
123
|
-
}
|
|
124
|
-
connection.connect(connectionConfig).then(function (connectionConfig) {
|
|
125
|
-
user = Object.freeze({
|
|
126
|
-
username: connectionConfig[0].sipLogin,
|
|
127
|
-
nickname: connectionConfig[0].sipVisibleName
|
|
128
|
-
});
|
|
129
|
-
state = SFU_STATE.AUTHENTICATED;
|
|
130
|
-
notify(SFU_EVENT.CONNECTED);
|
|
131
|
-
resolve(user);
|
|
132
|
-
}, function (e) {
|
|
133
|
-
state = SFU_STATE.FAILED;
|
|
134
|
-
notify(SFU_EVENT.FAILED, e);
|
|
135
|
-
reject(e);
|
|
136
|
-
});
|
|
137
|
-
});
|
|
138
|
-
};
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* Send message
|
|
142
|
-
* @param {Object} msg Message
|
|
143
|
-
* @param {String} msg.to Recipient's id (deprecated, use chatId instead)
|
|
144
|
-
* @param {String} msg.chatId Indicates chat this message belongs to
|
|
145
|
-
* @param {String} msg.body Message body
|
|
146
|
-
* @returns {Promise} Promise will resolve upon message delivery and reject if delivery was unsuccessful
|
|
147
|
-
* @throws {Error} error if api isn't connected
|
|
148
|
-
* @memberOf FlashphonerSFUExtended
|
|
149
|
-
*/
|
|
150
|
-
const sendMessage = function(msg) {
|
|
151
|
-
if (state !== SFU_STATE.AUTHENTICATED) {
|
|
152
|
-
throw new Error("Can't send message while in " + state + " state");
|
|
153
|
-
}
|
|
154
|
-
return im.sendMessage(msg);
|
|
155
|
-
};
|
|
156
|
-
|
|
157
|
-
/**
|
|
158
|
-
* Fetch available user list from server
|
|
159
|
-
* @returns {Promise<Array<FlashphonerSFUExtended.UserListEntry>>}
|
|
160
|
-
* @memberOf FlashphonerSFUExtended
|
|
161
|
-
|
|
162
|
-
*/
|
|
163
|
-
const getUserList = function() {
|
|
164
|
-
return new Promise(function (resolve, reject){
|
|
165
|
-
if (state !== SFU_STATE.AUTHENTICATED) {
|
|
166
|
-
reject(new Error("Can't get user list while in " + state + " state"));
|
|
167
|
-
return;
|
|
168
|
-
}
|
|
169
|
-
const id = uuidv4();
|
|
170
|
-
promises.add(id, resolve, reject);
|
|
171
|
-
connection.send(constants.SFU_INTERNAL_API.GET_USER_LIST, {internalMessageId: id});
|
|
172
|
-
});
|
|
173
|
-
};
|
|
174
|
-
|
|
175
|
-
/**
|
|
176
|
-
* Fetch available calendar from server
|
|
177
|
-
* @returns {Promise<Array<FlashphonerSFUExtended.UserCalendar>>}
|
|
178
|
-
* @memberOf FlashphonerSFUExtended
|
|
179
|
-
|
|
180
|
-
*/
|
|
181
|
-
const getUserCalendar = function() {
|
|
182
|
-
return new Promise(function (resolve, reject){
|
|
183
|
-
if (state !== SFU_STATE.AUTHENTICATED) {
|
|
184
|
-
reject(new Error("Can't get user calendar while in " + state + " state"));
|
|
185
|
-
return;
|
|
186
|
-
}
|
|
187
|
-
const id = uuidv4();
|
|
188
|
-
promises.add(id, resolve, reject);
|
|
189
|
-
connection.send(constants.SFU_INTERNAL_API.GET_USER_CALENDAR, {internalMessageId: id});
|
|
190
|
-
});
|
|
191
|
-
};
|
|
192
|
-
|
|
193
|
-
/**
|
|
194
|
-
* Add event to the calendar
|
|
195
|
-
* @param event {FlashphonerSFUExtended.UserCalendarEvent}
|
|
196
|
-
* @returns {Promise<void|error>}
|
|
197
|
-
* @memberOf FlashphonerSFUExtended
|
|
198
|
-
|
|
199
|
-
*/
|
|
200
|
-
const addCalendarEvent = function(event) {
|
|
201
|
-
return new Promise(function(resolve, reject){
|
|
202
|
-
if (state !== SFU_STATE.AUTHENTICATED) {
|
|
203
|
-
reject(new Error("Can't add calendar event while in " + state + " state"));
|
|
204
|
-
return;
|
|
205
|
-
}
|
|
206
|
-
const id = uuidv4();
|
|
207
|
-
promises.add(id, resolve, reject);
|
|
208
|
-
connection.send(constants.SFU_INTERNAL_API.ADD_CALENDAR_EVENT, {
|
|
209
|
-
internalMessageId: id,
|
|
210
|
-
event: event
|
|
211
|
-
});
|
|
212
|
-
});
|
|
213
|
-
};
|
|
214
|
-
|
|
215
|
-
/**
|
|
216
|
-
* Remove event from the calendar
|
|
217
|
-
* @param event {FlashphonerSFUExtended.UserCalendarEvent}
|
|
218
|
-
* @returns {Promise<void|error>}
|
|
219
|
-
* @memberOf FlashphonerSFUExtended
|
|
220
|
-
|
|
221
|
-
*/
|
|
222
|
-
const removeCalendarEvent = function(event) {
|
|
223
|
-
return new Promise(function(resolve, reject){
|
|
224
|
-
if (state !== SFU_STATE.AUTHENTICATED) {
|
|
225
|
-
reject(new Error("Can't remove calendar event while in " + state + " state"));
|
|
226
|
-
return;
|
|
227
|
-
}
|
|
228
|
-
const id = uuidv4();
|
|
229
|
-
promises.add(id, resolve, reject);
|
|
230
|
-
connection.send(constants.SFU_INTERNAL_API.REMOVE_CALENDAR_EVENT, {
|
|
231
|
-
internalMessageId: id,
|
|
232
|
-
event: event
|
|
233
|
-
});
|
|
234
|
-
});
|
|
235
|
-
};
|
|
236
|
-
|
|
237
|
-
/**
|
|
238
|
-
* Fetch available chats from server
|
|
239
|
-
* @returns {Promise<Array<FlashphonerSFUExtended.UserCalendar>>}
|
|
240
|
-
* @memberOf FlashphonerSFUExtended
|
|
241
|
-
*/
|
|
242
|
-
const getUserChats = function() {
|
|
243
|
-
return new Promise(function (resolve, reject){
|
|
244
|
-
if (state !== SFU_STATE.AUTHENTICATED) {
|
|
245
|
-
reject(new Error("Can't get user chats while in " + state + " state"));
|
|
246
|
-
return;
|
|
247
|
-
}
|
|
248
|
-
const id = uuidv4();
|
|
249
|
-
promises.add(id, resolve, reject);
|
|
250
|
-
connection.send(constants.SFU_INTERNAL_API.GET_USER_CHATS, {internalMessageId: id});
|
|
251
|
-
});
|
|
252
|
-
};
|
|
253
|
-
|
|
254
|
-
/**
|
|
255
|
-
* Fetch chat data from server
|
|
256
|
-
* @returns {Promise<Array<FlashphonerSFUExtended.UserCalendar>>}
|
|
257
|
-
* @memberOf FlashphonerSFUExtended
|
|
258
|
-
*/
|
|
259
|
-
const loadChat = function(chat) {
|
|
260
|
-
return new Promise(function (resolve, reject){
|
|
261
|
-
if (state !== SFU_STATE.AUTHENTICATED) {
|
|
262
|
-
reject(new Error("Can't load chats while in " + state + " state"));
|
|
263
|
-
return;
|
|
264
|
-
}
|
|
265
|
-
const id = uuidv4();
|
|
266
|
-
promises.add(id, resolve, reject);
|
|
267
|
-
connection.send(constants.SFU_INTERNAL_API.LOAD_CHAT, {id: chat.id, internalMessageId: id});
|
|
268
|
-
});
|
|
269
|
-
};
|
|
270
|
-
|
|
271
|
-
/**
|
|
272
|
-
* Create chat
|
|
273
|
-
* @returns {Promise<Array<FlashphonerSFUExtended.UserCalendar>>}
|
|
274
|
-
* @memberOf FlashphonerSFUExtended
|
|
275
|
-
*/
|
|
276
|
-
const createChat = function(chat) {
|
|
277
|
-
return new Promise(function (resolve, reject){
|
|
278
|
-
if (state !== SFU_STATE.AUTHENTICATED) {
|
|
279
|
-
reject(new Error("Can't create chats while in " + state + " state"));
|
|
280
|
-
return;
|
|
281
|
-
}
|
|
282
|
-
const id = uuidv4();
|
|
283
|
-
promises.add(id, resolve, reject);
|
|
284
|
-
connection.send(constants.SFU_INTERNAL_API.CREATE_CHAT, {id: chat.id, name: chat.name, members: chat.members, internalMessageId: id});
|
|
285
|
-
});
|
|
286
|
-
};
|
|
287
|
-
|
|
288
|
-
/**
|
|
289
|
-
* Delete chat
|
|
290
|
-
* @returns {Promise<Array<FlashphonerSFUExtended.UserCalendar>>}
|
|
291
|
-
* @memberOf FlashphonerSFUExtended
|
|
292
|
-
*/
|
|
293
|
-
const deleteChat = function(chat) {
|
|
294
|
-
return new Promise(function (resolve, reject){
|
|
295
|
-
if (state !== SFU_STATE.AUTHENTICATED) {
|
|
296
|
-
reject(new Error("Can't delete chats while in " + state + " state"));
|
|
297
|
-
return;
|
|
298
|
-
}
|
|
299
|
-
const id = uuidv4();
|
|
300
|
-
promises.add(id, resolve, reject);
|
|
301
|
-
connection.send(constants.SFU_INTERNAL_API.DELETE_CHAT, {id: chat.id, internalMessageId: id});
|
|
302
|
-
});
|
|
303
|
-
};
|
|
304
|
-
|
|
305
|
-
/**
|
|
306
|
-
* Rename chat
|
|
307
|
-
* @returns {Promise<Array<FlashphonerSFUExtended.UserCalendar>>}
|
|
308
|
-
* @memberOf FlashphonerSFUExtended
|
|
309
|
-
*/
|
|
310
|
-
const renameChat = function(chat) {
|
|
311
|
-
return new Promise(function (resolve, reject){
|
|
312
|
-
if (state !== SFU_STATE.AUTHENTICATED) {
|
|
313
|
-
reject(new Error("Can't rename chats while in " + state + " state"));
|
|
314
|
-
return;
|
|
315
|
-
}
|
|
316
|
-
const id = uuidv4();
|
|
317
|
-
promises.add(id, resolve, reject);
|
|
318
|
-
connection.send(constants.SFU_INTERNAL_API.RENAME_CHAT, {id: chat.id, name: chat.name, internalMessageId: id});
|
|
319
|
-
});
|
|
320
|
-
};
|
|
321
|
-
|
|
322
|
-
/**
|
|
323
|
-
* Add member to chat
|
|
324
|
-
* @returns {Promise<Array<FlashphonerSFUExtended.UserCalendar>>}
|
|
325
|
-
* @memberOf FlashphonerSFUExtended
|
|
326
|
-
*/
|
|
327
|
-
const addMemberToChat = function(chat) {
|
|
328
|
-
return new Promise(function (resolve, reject){
|
|
329
|
-
if (state !== SFU_STATE.AUTHENTICATED) {
|
|
330
|
-
reject(new Error("Can't add member to chat while in " + state + " state"));
|
|
331
|
-
return;
|
|
332
|
-
}
|
|
333
|
-
const id = uuidv4();
|
|
334
|
-
promises.add(id, resolve, reject);
|
|
335
|
-
connection.send(constants.SFU_INTERNAL_API.ADD_MEMBER_TO_CHAT, {id: chat.id, member: chat.member, internalMessageId: id});
|
|
336
|
-
});
|
|
337
|
-
};
|
|
338
|
-
|
|
339
|
-
/**
|
|
340
|
-
* Remove member from chat
|
|
341
|
-
* @returns {Promise<Array<FlashphonerSFUExtended.UserCalendar>>}
|
|
342
|
-
* @memberOf FlashphonerSFUExtended
|
|
343
|
-
*/
|
|
344
|
-
const removeMemberFromChat = function(chat) {
|
|
345
|
-
return new Promise(function (resolve, reject){
|
|
346
|
-
if (state !== SFU_STATE.AUTHENTICATED) {
|
|
347
|
-
reject(new Error("Can't remove member to chat while in " + state + " state"));
|
|
348
|
-
return;
|
|
349
|
-
}
|
|
350
|
-
const id = uuidv4();
|
|
351
|
-
promises.add(id, resolve, reject);
|
|
352
|
-
connection.send(constants.SFU_INTERNAL_API.REMOVE_MEMBER_FROM_CHAT, {id: chat.id, member: chat.member, internalMessageId: id});
|
|
353
|
-
});
|
|
354
|
-
};
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
/**
|
|
358
|
-
* Create room
|
|
359
|
-
*
|
|
360
|
-
* @param {Object} options Room options
|
|
361
|
-
* @param {String} options.name Room name
|
|
362
|
-
* @param {String} options.pin Room's pin
|
|
363
|
-
* @param {Object} options.pc Peer connection
|
|
364
|
-
* @returns {FlashphonerSFU.Room} Room
|
|
365
|
-
* @throws {TypeError} Error if no options provided
|
|
366
|
-
* @throws {Error} error if api isn't connected
|
|
367
|
-
* @memberof FlashphonerSFUExtended
|
|
368
|
-
*/
|
|
369
|
-
const room = function(options) {
|
|
370
|
-
if (!options) {
|
|
371
|
-
throw new TypeError("No options provided");
|
|
372
|
-
}
|
|
373
|
-
if (state !== SFU_STATE.AUTHENTICATED) {
|
|
374
|
-
throw new Error("Can't create room while in " + state + " state");
|
|
375
|
-
}
|
|
376
|
-
const opt = {
|
|
377
|
-
connection: connection,
|
|
378
|
-
name: options.name,
|
|
379
|
-
pin: options.pin,
|
|
380
|
-
pc: options.pc
|
|
381
|
-
};
|
|
382
|
-
const exports = roomApi.room(opt);
|
|
383
|
-
rooms[options.name] = exports;
|
|
384
|
-
const cleanup = function() {
|
|
385
|
-
rooms[options.name].pc().close();
|
|
386
|
-
rooms[options.name].pc().dispatchEvent(new Event("connectionstatechange"));
|
|
387
|
-
delete rooms[options.name];
|
|
388
|
-
};
|
|
389
|
-
exports.on(constants.SFU_ROOM_EVENT.LEFT, function(participant){
|
|
390
|
-
if (participant.name === user.nickname) {
|
|
391
|
-
cleanup();
|
|
392
|
-
}
|
|
393
|
-
}).on(constants.SFU_ROOM_EVENT.EVICTED, function(participant) {
|
|
394
|
-
if (participant.name === user.nickname) {
|
|
395
|
-
cleanup();
|
|
396
|
-
}
|
|
397
|
-
}).on(constants.SFU_ROOM_EVENT.FAILED, cleanup
|
|
398
|
-
).on(constants.SFU_ROOM_EVENT.OPERATION_FAILED, function(e) {
|
|
399
|
-
if (constants.SFU_OPERATIONS.ROOM_JOIN === e.operation) {
|
|
400
|
-
cleanup();
|
|
401
|
-
}
|
|
402
|
-
});
|
|
403
|
-
return exports;
|
|
404
|
-
};
|
|
405
|
-
|
|
406
|
-
/**
|
|
407
|
-
* FlashphonerSFUExtended event callback.
|
|
408
|
-
*
|
|
409
|
-
* @callback FlashphonerSFUExtended~eventCallback
|
|
410
|
-
* @param {FlashphonerSFUExtended} sdk instance FlashphonerSFUExtended
|
|
411
|
-
*/
|
|
412
|
-
|
|
413
|
-
/**
|
|
414
|
-
* Add session event callback.
|
|
415
|
-
*
|
|
416
|
-
* @param {String} event One of {@link FlashphonerSFU.SFU_EVENT} events
|
|
417
|
-
* @param {FlashphonerSFUExtended~eventCallback} callback Callback function
|
|
418
|
-
* @returns {FlashphonerSFUExtended} SDK instance callback was attached to
|
|
419
|
-
* @throws {TypeError} Error if event is not specified
|
|
420
|
-
* @throws {Error} Error if callback is not a valid function
|
|
421
|
-
* @memberOf FlashphonerSFUExtended
|
|
422
|
-
*/
|
|
423
|
-
const on = function (event, callback) {
|
|
424
|
-
if (!event) {
|
|
425
|
-
throw new TypeError("Event can't be null");
|
|
426
|
-
}
|
|
427
|
-
if (!callback || typeof callback !== "function") {
|
|
428
|
-
throw new Error("Callback needs to be a valid function");
|
|
429
|
-
}
|
|
430
|
-
if (!callbacks[event]) {
|
|
431
|
-
callbacks[event] = [];
|
|
432
|
-
}
|
|
433
|
-
callbacks[event].push(callback);
|
|
434
|
-
return sfu;
|
|
435
|
-
};
|
|
436
|
-
|
|
437
|
-
const notify = function(event, msg) {
|
|
438
|
-
if (callbacks[event]) {
|
|
439
|
-
for (const callback of callbacks[event]) {
|
|
440
|
-
callback(msg);
|
|
441
|
-
}
|
|
442
|
-
}
|
|
443
|
-
};
|
|
444
|
-
|
|
445
|
-
/**
|
|
446
|
-
* Disconnect sfu from the server
|
|
447
|
-
* @memberOf FlashphonerSFUExtended
|
|
448
|
-
*/
|
|
449
|
-
const disconnect = function() {
|
|
450
|
-
for (const [key, value] of Object.entries(rooms)) {
|
|
451
|
-
value.leaveRoom();
|
|
452
|
-
}
|
|
453
|
-
user = undefined;
|
|
454
|
-
connection.close();
|
|
455
|
-
connection = ws.createConnection();
|
|
456
|
-
state = SFU_STATE.DISCONNECTED;
|
|
457
|
-
rooms = {};
|
|
458
|
-
};
|
|
459
|
-
|
|
460
|
-
sfu.on = on;
|
|
461
|
-
sfu.connect = connect;
|
|
462
|
-
sfu.sendMessage = sendMessage;
|
|
463
|
-
sfu.getUserList = getUserList;
|
|
464
|
-
sfu.getUserCalendar = getUserCalendar;
|
|
465
|
-
sfu.addCalendarEvent = addCalendarEvent;
|
|
466
|
-
sfu.removeCalendarEvent = removeCalendarEvent;
|
|
467
|
-
sfu.getUserChats = getUserChats;
|
|
468
|
-
sfu.loadChat = loadChat;
|
|
469
|
-
sfu.createChat = createChat;
|
|
470
|
-
sfu.deleteChat = deleteChat;
|
|
471
|
-
sfu.renameChat = renameChat;
|
|
472
|
-
sfu.addMemberToChat = addMemberToChat;
|
|
473
|
-
sfu.removeMemberFromChat = removeMemberFromChat;
|
|
474
|
-
sfu.room = room;
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
/**
|
|
478
|
-
* @typedef {Object} SFUUser
|
|
479
|
-
* @property username {String} username
|
|
480
|
-
* @property nickname {String} nickname
|
|
481
|
-
* @memberOf FlashphonerSFUExtended
|
|
482
|
-
*/
|
|
483
|
-
|
|
484
|
-
/**
|
|
485
|
-
* Get current user
|
|
486
|
-
* @returns {FlashphonerSFUExtended.SFUUser} Returns current logged in user
|
|
487
|
-
* @memberOf FlashphonerSFUExtended
|
|
488
|
-
*/
|
|
489
|
-
sfu.user = function(){
|
|
490
|
-
return user;
|
|
491
|
-
};
|
|
492
|
-
/**
|
|
493
|
-
* Get hostname of the server in use
|
|
494
|
-
* @returns {String} Current server's hostname
|
|
495
|
-
* @memberOf FlashphonerSFUExtended
|
|
496
|
-
*/
|
|
497
|
-
sfu.server = function() {
|
|
498
|
-
return server;
|
|
499
|
-
};
|
|
500
|
-
sfu.disconnect = disconnect;
|
|
501
|
-
|
|
502
|
-
/**
|
|
503
|
-
* Get sfu state
|
|
504
|
-
* @returns {FlashphonerSFU.SFU_STATE} Current sfu state
|
|
505
|
-
*/
|
|
506
|
-
sfu.state = function() {
|
|
507
|
-
return state;
|
|
508
|
-
};
|
|
509
|
-
|
|
510
|
-
sfu.constants = constants;
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
module.exports = sfu;
|
package/src/sdk/sfu.js
DELETED
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @namespace FlashphonerSFU
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
const ws = require("./ws");
|
|
6
|
-
const roomApi = require("./room");
|
|
7
|
-
const constants = require("./constants");
|
|
8
|
-
const SFU_STATE = constants.SFU_STATE;
|
|
9
|
-
const SFU_EVENT = constants.SFU_EVENT;
|
|
10
|
-
const SFU_INTERNAL = constants.SFU_INTERNAL_API;
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Connect to server and create local representation of the room.
|
|
14
|
-
* @param {Object} options Room options
|
|
15
|
-
* @param {String} options.url Server url
|
|
16
|
-
* @param {String} options.roomName Room name
|
|
17
|
-
* @param {String} options.pin Room's pin
|
|
18
|
-
* @param {String} options.nickname Participant's nick
|
|
19
|
-
* @param {Object} options.pc Peer connection
|
|
20
|
-
* @returns {FlashphonerSFU.SFUSession} session
|
|
21
|
-
* @throws {TypeError} Error if no options provided
|
|
22
|
-
* @memberof FlashphonerSFU
|
|
23
|
-
*/
|
|
24
|
-
function createSession(options) {
|
|
25
|
-
if (!options) {
|
|
26
|
-
throw new TypeError("No options provided");
|
|
27
|
-
}
|
|
28
|
-
let sfu = {};
|
|
29
|
-
let room;
|
|
30
|
-
const callbacks = {};
|
|
31
|
-
const connection = ws.createConnection();
|
|
32
|
-
let state = SFU_STATE.NEW;
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
connection.onMessage = function(name, msg){
|
|
36
|
-
switch (name) {
|
|
37
|
-
case SFU_INTERNAL.DEFAULT_METHOD:
|
|
38
|
-
if (msg[0].roomName && msg[0].roomName.length > 0) {
|
|
39
|
-
//room event
|
|
40
|
-
if (room) {
|
|
41
|
-
room.processEvent(msg[0]);
|
|
42
|
-
}
|
|
43
|
-
} else {
|
|
44
|
-
notify(msg[0].type, msg[0]);
|
|
45
|
-
}
|
|
46
|
-
break;
|
|
47
|
-
case "failed":
|
|
48
|
-
notify(constants.SFU_EVENT.FAILED, msg[0]);
|
|
49
|
-
break;
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
connection.onClose = function(e) {
|
|
54
|
-
state = SFU_STATE.DISCONNECTED;
|
|
55
|
-
notify(SFU_EVENT.DISCONNECTED, e);
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
connection.onError = function(e) {
|
|
59
|
-
state = SFU_STATE.FAILED;
|
|
60
|
-
notify(SFU_STATE.FAILED, e);
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
let connectionConfig = {
|
|
64
|
-
url: options.url,
|
|
65
|
-
appName: SFU_INTERNAL.P_APP,
|
|
66
|
-
custom: {
|
|
67
|
-
nickname: options.nickname,
|
|
68
|
-
roomName: options.roomName
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
connection.connect(connectionConfig).then(function (connectionConfig) {
|
|
73
|
-
state = SFU_STATE.CONNECTED;
|
|
74
|
-
//create room
|
|
75
|
-
const opt = {
|
|
76
|
-
connection: connection,
|
|
77
|
-
name: options.roomName,
|
|
78
|
-
pin: options.pin,
|
|
79
|
-
pc: options.pc
|
|
80
|
-
};
|
|
81
|
-
room = roomApi.room(opt);
|
|
82
|
-
notify(SFU_EVENT.CONNECTED, room);
|
|
83
|
-
}, function (e) {
|
|
84
|
-
state = SFU_STATE.FAILED;
|
|
85
|
-
notify(SFU_EVENT.FAILED, e);
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* Disconnect from the server
|
|
90
|
-
* @memberOf FlashphonerSFU.SFUSession
|
|
91
|
-
*/
|
|
92
|
-
const disconnect = function() {
|
|
93
|
-
connection.close();
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* Session event callback.
|
|
98
|
-
*
|
|
99
|
-
* @callback FlashphonerSFU.SFUSession~eventCallback
|
|
100
|
-
* @param {FlashphonerSFU.SFUSession} session SFUSession that corresponds to the event
|
|
101
|
-
*/
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* Add session event callback.
|
|
105
|
-
*
|
|
106
|
-
* @param {String} event One of {@link FlashphonerSFU.SFU_EVENT} events
|
|
107
|
-
* @param {FlashphonerSFU.SFUSession~eventCallback} callback Callback function
|
|
108
|
-
* @returns {FlashphonerSFU.SFUSession} Session callback was attached to
|
|
109
|
-
* @throws {TypeError} Error if event is not specified
|
|
110
|
-
* @throws {Error} Error if callback is not a valid function
|
|
111
|
-
* @memberOf FlashphonerSFU.SFUSession
|
|
112
|
-
* @inner
|
|
113
|
-
*/
|
|
114
|
-
const on = function (event, callback) {
|
|
115
|
-
if (!event) {
|
|
116
|
-
throw new TypeError("Event can't be null");
|
|
117
|
-
}
|
|
118
|
-
if (!callback || typeof callback !== "function") {
|
|
119
|
-
throw new Error("Callback needs to be a valid function");
|
|
120
|
-
}
|
|
121
|
-
if (!callbacks[event]) {
|
|
122
|
-
callbacks[event] = [];
|
|
123
|
-
}
|
|
124
|
-
callbacks[event].push(callback);
|
|
125
|
-
return sfu;
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
const notify = function(event, msg) {
|
|
129
|
-
if (callbacks[event]) {
|
|
130
|
-
for (const callback of callbacks[event]) {
|
|
131
|
-
callback(msg);
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
};
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* Represents connection to server. Once connected will emmit {@link FlashphonerSFU.SFU_EVENT.CONNECTED} with local instance of previously
|
|
138
|
-
* specified room.
|
|
139
|
-
*
|
|
140
|
-
* @see FlashphonerSFU.createSession
|
|
141
|
-
* @namespace SFUSession
|
|
142
|
-
* @memberOf FlashphonerSFU
|
|
143
|
-
*/
|
|
144
|
-
sfu = {
|
|
145
|
-
/**
|
|
146
|
-
* Returns room object if available
|
|
147
|
-
* @returns {FlashphonerSFU.Room}
|
|
148
|
-
* @memberOf FlashphonerSFU.SFUSession
|
|
149
|
-
*/
|
|
150
|
-
room: function() {
|
|
151
|
-
return room;
|
|
152
|
-
},
|
|
153
|
-
/**
|
|
154
|
-
* Returns {@link FlashphonerSFU.SFU_STATE} state of connection
|
|
155
|
-
* @returns {FlashphonerSFU.SFU_STATE}
|
|
156
|
-
* @memberOf FlashphonerSFU.SFUSession
|
|
157
|
-
*/
|
|
158
|
-
state: function() {
|
|
159
|
-
return state;
|
|
160
|
-
},
|
|
161
|
-
/**
|
|
162
|
-
* Preconfigured nickname
|
|
163
|
-
* @returns {String}
|
|
164
|
-
* @memberOf FlashphonerSFU.SFUSession
|
|
165
|
-
*/
|
|
166
|
-
nickname: function() {
|
|
167
|
-
return options.nickname;
|
|
168
|
-
},
|
|
169
|
-
disconnect: disconnect,
|
|
170
|
-
on: on
|
|
171
|
-
}
|
|
172
|
-
return sfu;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
module.exports = {
|
|
177
|
-
createRoom: createSession,
|
|
178
|
-
constants: constants
|
|
179
|
-
}
|