openvidu-node-client: builder pattern to object pattern

pull/73/head
pabloFuente 2018-04-23 11:06:16 +02:00
parent 43894c215b
commit 60948f7607
20 changed files with 135 additions and 312 deletions

View File

@ -1,7 +1,7 @@
import { Session } from "./Session";
import { SessionProperties } from "./SessionProperties";
import { Recording } from "./Recording";
import { RecordingProperties } from "./RecordingProperties";
import { Session } from './Session';
import { SessionProperties } from './SessionProperties';
import { Recording } from './Recording';
import { RecordingProperties } from './RecordingProperties';
export declare class OpenVidu {
private urlOpenViduServer;
private static readonly API_RECORDINGS;

View File

@ -37,9 +37,9 @@ var OpenVidu = /** @class */ (function () {
var properties = param2;
requestBody = JSON.stringify({
session: sessionId,
name: properties.name(),
recordingLayout: (!!properties.recordingLayout() ? properties.recordingLayout() : ''),
customLayout: (!!properties.customLayout() ? properties.customLayout() : '')
name: !!properties.name ? properties.name : '',
recordingLayout: !!properties.recordingLayout ? properties.recordingLayout : '',
customLayout: !!properties.customLayout ? properties.customLayout : ''
});
}
else {
@ -191,9 +191,10 @@ var OpenVidu = /** @class */ (function () {
if (res.statusCode === 200) {
// SUCCESS response from openvidu-server (JSON arrays of recordings in JSON format). Resolve list of new recordings
var recordingArray = [];
var responseItems = JSON.parse(body)['items'];
for (var i = 0; i < responseItems.length; i++) {
recordingArray.push(new Recording_1.Recording(responseItems[i]));
var responseItems = JSON.parse(body).items;
for (var _i = 0, responseItems_1 = responseItems; _i < responseItems_1.length; _i++) {
var item = responseItems_1[_i];
recordingArray.push(new Recording_1.Recording(item));
}
resolve(recordingArray);
}
@ -256,7 +257,7 @@ var OpenVidu = /** @class */ (function () {
this.hostname = this.urlOpenViduServer.split(':')[1].replace(/\//g, '');
this.port = parseInt(this.urlOpenViduServer.split(':')[2].replace(/\//g, ''));
}
else if (urlSplitted.length == 2) {
else if (urlSplitted.length === 2) {
this.hostname = this.urlOpenViduServer.split(':')[0].replace(/\//g, '');
this.port = parseInt(this.urlOpenViduServer.split(':')[1].replace(/\//g, ''));
}

File diff suppressed because one or more lines are too long

View File

@ -20,6 +20,6 @@ var OpenViduRole;
(function (OpenViduRole) {
OpenViduRole["SUBSCRIBER"] = "SUBSCRIBER";
OpenViduRole["PUBLISHER"] = "PUBLISHER";
OpenViduRole["MODERATOR"] = "MODERATOR"; // SUBSCRIBER + PUBLIHSER permissions + can force unpublish() and disconnect() over a third-party stream or user
OpenViduRole["MODERATOR"] = "MODERATOR";
})(OpenViduRole = exports.OpenViduRole || (exports.OpenViduRole = {}));
//# sourceMappingURL=OpenViduRole.js.map

View File

@ -1 +1 @@
{"version":3,"file":"OpenViduRole.js","sourceRoot":"","sources":["../src/OpenViduRole.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;AAEH,IAAY,YAIX;AAJD,WAAY,YAAY;IACvB,yCAAyB,CAAA;IACzB,uCAAuB,CAAA;IACvB,uCAAuB,CAAA,CAAE,gHAAgH;AAC1I,CAAC,EAJW,YAAY,GAAZ,oBAAY,KAAZ,oBAAY,QAIvB"}
{"version":3,"file":"OpenViduRole.js","sourceRoot":"","sources":["../src/OpenViduRole.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;AAEH,IAAY,YAIX;AAJD,WAAY,YAAY;IACvB,yCAAyB,CAAA;IACzB,uCAAuB,CAAA;IACvB,uCAAuB,CAAA;AACxB,CAAC,EAJW,YAAY,GAAZ,oBAAY,KAAZ,oBAAY,QAIvB"}

View File

@ -1,5 +1,5 @@
import { TokenOptions } from './TokenOptions';
import { SessionProperties } from './SessionProperties';
import { TokenOptions } from './TokenOptions';
export declare class Session {
private hostname;
private port;

View File

@ -16,17 +16,19 @@
*
*/
Object.defineProperty(exports, "__esModule", { value: true });
var MediaMode_1 = require("./MediaMode");
var OpenViduRole_1 = require("./OpenViduRole");
var SessionProperties_1 = require("./SessionProperties");
var RecordingLayout_1 = require("./RecordingLayout");
var RecordingMode_1 = require("./RecordingMode");
var https = require('https');
var Session = /** @class */ (function () {
function Session(hostname, port, basicAuth, properties) {
this.hostname = hostname;
this.port = port;
this.basicAuth = basicAuth;
this.sessionId = "";
if (properties == null) {
this.properties = new SessionProperties_1.SessionProperties.Builder().build();
this.sessionId = '';
if (properties === null) {
this.properties = {};
}
else {
this.properties = properties;
@ -39,10 +41,10 @@ var Session = /** @class */ (function () {
resolve(_this.sessionId);
}
var requestBody = JSON.stringify({
'mediaMode': _this.properties.mediaMode(),
'recordingMode': _this.properties.recordingMode(),
'defaultRecordingLayout': _this.properties.defaultRecordingLayout(),
'defaultCustomLayout': _this.properties.defaultCustomLayout()
mediaMode: !!_this.properties.mediaMode ? _this.properties.mediaMode : MediaMode_1.MediaMode.ROUTED,
recordingMode: !!_this.properties.recordingMode ? _this.properties.recordingMode : RecordingMode_1.RecordingMode.MANUAL,
defaultRecordingLayout: !!_this.properties.defaultRecordingLayout ? _this.properties.defaultRecordingLayout : RecordingLayout_1.RecordingLayout.BEST_FIT,
defaultCustomLayout: !!_this.properties.defaultCustomLayout ? _this.properties.defaultCustomLayout : ''
});
var options = {
hostname: _this.hostname,
@ -84,21 +86,11 @@ var Session = /** @class */ (function () {
Session.prototype.generateToken = function (tokenOptions) {
var _this = this;
return new Promise(function (resolve, reject) {
var requestBody;
if (!!tokenOptions) {
requestBody = JSON.stringify({
'session': _this.sessionId,
'role': tokenOptions.getRole(),
'data': tokenOptions.getData()
var requestBody = JSON.stringify({
session: _this.sessionId,
role: !!tokenOptions.role ? tokenOptions.role : OpenViduRole_1.OpenViduRole.PUBLISHER,
data: !!tokenOptions.data ? tokenOptions.data : ''
});
}
else {
requestBody = JSON.stringify({
'session': _this.sessionId,
'role': OpenViduRole_1.OpenViduRole.PUBLISHER,
'data': ''
});
}
var options = {
hostname: _this.hostname,
port: _this.port,

View File

@ -1 +1 @@
{"version":3,"file":"Session.js","sourceRoot":"","sources":["../src/Session.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;AAGH,+CAA8C;AAC9C,yDAAwD;AAKxD,IAAI,KAAK,GAAG,OAAO,C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AAC;YACvB,GAAG,CAAC,GAAG,EAAE,CAAC;QACd,CAAC,CAAC,CAAC;IACP,CAAC;IAEM,+BAAa,GAApB;QACI,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC;IAC3B,CAAC;IApHuB,oBAAY,GAAG,eAAe,CAAC;IAC/B,kBAAU,GAAG,aAAa,CAAC;IAqHvD,cAAC;CAAA,AAxHD,IAwHC;AAxHY,0BAAO"}

View File

@ -1,17 +1,5 @@
import { OpenViduRole } from "./OpenViduRole";
export declare class TokenOptions {
private data;
private role;
constructor(data: string, role: OpenViduRole);
getData(): string;
getRole(): OpenViduRole;
}
export declare namespace TokenOptions {
class Builder {
private dataProp;
private roleProp;
build(): TokenOptions;
data(data: string): Builder;
role(role: OpenViduRole): Builder;
}
import { OpenViduRole } from './OpenViduRole';
export interface TokenOptions {
data: string;
role: OpenViduRole;
}

View File

@ -16,42 +16,4 @@
*
*/
Object.defineProperty(exports, "__esModule", { value: true });
var OpenViduRole_1 = require("./OpenViduRole");
var TokenOptions = /** @class */ (function () {
function TokenOptions(data, role) {
this.data = data;
this.role = role;
}
TokenOptions.prototype.getData = function () {
return this.data;
};
TokenOptions.prototype.getRole = function () {
return this.role;
};
return TokenOptions;
}());
exports.TokenOptions = TokenOptions;
(function (TokenOptions) {
var Builder = /** @class */ (function () {
function Builder() {
this.dataProp = '';
this.roleProp = OpenViduRole_1.OpenViduRole.PUBLISHER;
}
Builder.prototype.build = function () {
return new TokenOptions(this.dataProp, this.roleProp);
};
Builder.prototype.data = function (data) {
this.dataProp = data;
return this;
};
Builder.prototype.role = function (role) {
this.roleProp = role;
return this;
};
return Builder;
}());
TokenOptions.Builder = Builder;
;
})(TokenOptions = exports.TokenOptions || (exports.TokenOptions = {}));
exports.TokenOptions = TokenOptions;
//# sourceMappingURL=TokenOptions.js.map

View File

@ -1 +1 @@
{"version":3,"file":"TokenOptions.js","sourceRoot":"","sources":["../src/TokenOptions.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;AAEH,+CAA8C;AAE9C;IAEI,sBAAoB,IAAY,EAAU,IAAkB;QAAxC,SAAI,GAAJ,IAAI,CAAQ;QAAU,SAAI,GAAJ,IAAI,CAAc;IAAI,CAAC;IAEjE,8BAAO,GAAP;QACI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC;IACrB,CAAC;IAED,8BAAO,GAAP;QACI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC;IACrB,CAAC;IACL,mBAAC;AAAD,CAAC,AAXD,IAWC;AAXY,oCAAY;AAazB,WAAiB,YAAY;IACzB;QAAA;YAEY,aAAQ,GAAW,EAAE,CAAC;YACtB,aAAQ,GAAiB,2BAAY,CAAC,SAAS,CAAC;QAgB5D,CAAC;QAdG,uBAAK,GAAL;YACI,MAAM,CAAC,IAAI,YAAY,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC1D,CAAC;QAED,sBAAI,GAAJ,UAAK,IAAY;YACb,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;YACrB,MAAM,CAAC,IAAI,CAAC;QAChB,CAAC;QAED,sBAAI,GAAJ,UAAK,IAAkB;YACnB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;YACrB,MAAM,CAAC,IAAI,CAAC;QAChB,CAAC;QAEL,cAAC;IAAD,CAAC,AAnBD,IAmBC;IAnBY,oBAAO,UAmBnB,CAAA;IAAA,CAAC;AACN,CAAC,EArBgB,YAAY,GAAZ,oBAAY,KAAZ,oBAAY,QAqB5B;AAlCY,oCAAY"}
{"version":3,"file":"TokenOptions.js","sourceRoot":"","sources":["../src/TokenOptions.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG"}

View File

@ -6,11 +6,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
__export(require("./OpenVidu"));
__export(require("./OpenViduRole"));
__export(require("./Session"));
__export(require("./SessionProperties"));
__export(require("./TokenOptions"));
__export(require("./MediaMode"));
__export(require("./RecordingLayout"));
__export(require("./RecordingMode"));
__export(require("./Recording"));
__export(require("./RecordingProperties"));
//# sourceMappingURL=index.js.map

View File

@ -1 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;AAAA,gCAA2B;AAC3B,oCAA+B;AAC/B,+BAA0B;AAC1B,yCAAoC;AACpC,oCAA+B;AAC/B,iCAA4B;AAC5B,uCAAkC;AAClC,qCAAgC;AAChC,iCAA4B;AAC5B,2CAAsC"}
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;AAAA,gCAA2B;AAC3B,oCAA+B;AAC/B,+BAA0B;AAG1B,iCAA4B;AAC5B,uCAAkC;AAClC,qCAAgC;AAChC,iCAA4B"}

View File

@ -15,14 +15,14 @@
*
*/
import { Session } from "./Session";
import { SessionProperties } from "./SessionProperties";
import { Recording } from "./Recording";
import { RecordingProperties } from "./RecordingProperties";
import { RecordingLayout } from "./RecordingLayout";
import { Session } from './Session';
import { SessionProperties } from './SessionProperties';
import { Recording } from './Recording';
import { RecordingLayout } from './RecordingLayout';
import { RecordingProperties } from './RecordingProperties';
declare const Buffer;
let https = require('https');
const https = require('https');
export class OpenVidu {
@ -57,9 +57,9 @@ export class OpenVidu {
const properties = <RecordingProperties>param2;
requestBody = JSON.stringify({
session: sessionId,
name: properties.name(),
recordingLayout: (!!properties.recordingLayout() ? properties.recordingLayout() : ''),
customLayout: (!!properties.customLayout() ? properties.customLayout() : '')
name: !!properties.name ? properties.name : '',
recordingLayout: !!properties.recordingLayout ? properties.recordingLayout : '',
customLayout: !!properties.customLayout ? properties.customLayout : ''
});
} else {
requestBody = JSON.stringify({
@ -78,7 +78,7 @@ export class OpenVidu {
});
}
let options = {
const options = {
hostname: this.hostname,
port: this.port,
path: OpenVidu.API_RECORDINGS + OpenVidu.API_RECORDINGS_START,
@ -88,7 +88,8 @@ export class OpenVidu {
'Content-Type': 'application/json',
'Content-Length': Buffer.byteLength(requestBody)
}
}
};
const req = https.request(options, (res) => {
let body = '';
res.on('data', (d) => {
@ -118,7 +119,7 @@ export class OpenVidu {
public stopRecording(recordingId: string): Promise<Recording> {
return new Promise<Recording>((resolve, reject) => {
let options = {
const options = {
hostname: this.hostname,
port: this.port,
path: OpenVidu.API_RECORDINGS + OpenVidu.API_RECORDINGS_STOP + '/' + recordingId,
@ -127,7 +128,8 @@ export class OpenVidu {
'Authorization': this.basicAuth,
'Content-Type': 'application/x-www-form-urlencoded'
}
}
};
const req = https.request(options, (res) => {
let body = '';
res.on('data', (d) => {
@ -157,7 +159,7 @@ export class OpenVidu {
public getRecording(recordingId: string): Promise<Recording> {
return new Promise<Recording>((resolve, reject) => {
let options = {
const options = {
hostname: this.hostname,
port: this.port,
path: OpenVidu.API_RECORDINGS + '/' + recordingId,
@ -166,7 +168,8 @@ export class OpenVidu {
'Authorization': this.basicAuth,
'Content-Type': 'application/x-www-form-urlencoded'
}
}
};
const req = https.request(options, (res) => {
let body = '';
res.on('data', (d) => {
@ -196,7 +199,7 @@ export class OpenVidu {
public listRecordings(): Promise<Recording[]> {
return new Promise<Recording[]>((resolve, reject) => {
let options = {
const options = {
hostname: this.hostname,
port: this.port,
path: OpenVidu.API_RECORDINGS,
@ -205,7 +208,8 @@ export class OpenVidu {
'Authorization': this.basicAuth,
'Content-Type': 'application/x-www-form-urlencoded'
}
}
};
const req = https.request(options, (res) => {
let body = '';
res.on('data', (d) => {
@ -215,10 +219,10 @@ export class OpenVidu {
res.on('end', () => {
if (res.statusCode === 200) {
// SUCCESS response from openvidu-server (JSON arrays of recordings in JSON format). Resolve list of new recordings
let recordingArray: Recording[] = [];
let responseItems = JSON.parse(body)['items'];
for (let i = 0; i < responseItems.length; i++) {
recordingArray.push(new Recording(responseItems[i]));
const recordingArray: Recording[] = [];
const responseItems = JSON.parse(body).items;
for (const item of responseItems) {
recordingArray.push(new Recording(item));
}
resolve(recordingArray);
} else {
@ -240,7 +244,7 @@ export class OpenVidu {
public deleteRecording(recordingId: string): Promise<Error> {
return new Promise<Error>((resolve, reject) => {
let options = {
const options = {
hostname: this.hostname,
port: this.port,
path: OpenVidu.API_RECORDINGS + '/' + recordingId,
@ -249,7 +253,8 @@ export class OpenVidu {
'Authorization': this.basicAuth,
'Content-Type': 'application/x-www-form-urlencoded'
}
}
};
const req = https.request(options, (res) => {
let body = '';
res.on('data', (d) => {
@ -281,11 +286,11 @@ export class OpenVidu {
}
private setHostnameAndPort(): void {
let urlSplitted = this.urlOpenViduServer.split(':');
const urlSplitted = this.urlOpenViduServer.split(':');
if (urlSplitted.length === 3) { // URL has format: http:// + hostname + :port
this.hostname = this.urlOpenViduServer.split(':')[1].replace(/\//g, '');
this.port = parseInt(this.urlOpenViduServer.split(':')[2].replace(/\//g, ''));
} else if (urlSplitted.length == 2) { // URL has format: hostname + :port
} else if (urlSplitted.length === 2) { // URL has format: hostname + :port
this.hostname = this.urlOpenViduServer.split(':')[0].replace(/\//g, '');
this.port = parseInt(this.urlOpenViduServer.split(':')[1].replace(/\//g, ''));
} else {

View File

@ -18,5 +18,5 @@
export enum OpenViduRole {
SUBSCRIBER = 'SUBSCRIBER', // Can subscribe to published streams of other users
PUBLISHER = 'PUBLISHER', // SUBSCRIBER permissions + can subscribe to published streams of other users and publish their own streams
MODERATOR = 'MODERATOR' // SUBSCRIBER + PUBLIHSER permissions + can force unpublish() and disconnect() over a third-party stream or user
MODERATOR = 'MODERATOR', // SUBSCRIBER + PUBLIHSER permissions + can force unpublish() and disconnect() over a third-party stream or user
}

View File

@ -15,22 +15,23 @@
*
*/
import { RecordingProperties } from "./RecordingProperties";
import { RecordingLayout } from "./RecordingLayout";
import { RecordingLayout } from './RecordingLayout';
import { RecordingProperties } from './RecordingProperties';
export class Recording {
private id: string;
private sessionId: string;
private createdAt: number;
private size: number = 0;
private duration: number = 0;
private size = 0;
private duration = 0;
private url: string;
private hasaudio: boolean = true;
private hasvideo: boolean = true;
private hasaudio = true;
private hasvideo = true;
private status: Recording.Status;
private recordingProperties: RecordingProperties;
/* tslint:disable:no-string-literal */
constructor(json: JSON) {
this.id = json['id'];
this.sessionId = json['sessionId'];
@ -41,8 +42,9 @@ export class Recording {
this.hasaudio = json['hasAudio'];
this.hasvideo = json['hasVideo'];
this.status = json['status'];
this.recordingProperties = new RecordingProperties.Builder().name(json['name']).recordingLayout(json['layout']).build();
this.recordingProperties = { name: json['name'], recordingLayout: json['layout'] };
}
/* tslint:enable:no-string-literal */
public getStatus(): Recording.Status {
return this.status;
@ -53,11 +55,11 @@ export class Recording {
}
public getName(): string {
return this.recordingProperties.name();
return this.recordingProperties.name;
}
public getLayout(): RecordingLayout {
return this.recordingProperties.recordingLayout();
return this.recordingProperties.recordingLayout;
}
public getSessionId(): string {

View File

@ -15,50 +15,10 @@
*
*/
import { RecordingLayout } from "./RecordingLayout";
import { RecordingLayout } from './RecordingLayout';
export class RecordingProperties {
constructor(private rName: string, private recordingLayoutProp: RecordingLayout, private customLayoutProp: string) { }
name(): string {
return this.rName;
}
recordingLayout(): RecordingLayout {
return this.recordingLayoutProp;
}
customLayout(): string {
return this.customLayoutProp;
}
}
export namespace RecordingProperties {
export class Builder {
private rName: string = '';
private recordingLayoutProp: RecordingLayout;
private customLayoutProp: string;
build(): RecordingProperties {
return new RecordingProperties(this.rName, this.recordingLayoutProp, this.customLayoutProp);
}
name(name: string): Builder {
this.rName = name;
return this;
}
recordingLayout(layout: RecordingLayout): Builder {
this.recordingLayoutProp = layout;
return this;
}
customLayout(path: string): Builder {
this.customLayoutProp = path;
return this;
}
};
export interface RecordingProperties {
name?: string;
recordingLayout?: RecordingLayout;
customLayout?: string;
}

View File

@ -15,26 +15,29 @@
*
*/
import { TokenOptions } from './TokenOptions';
import { MediaMode } from './MediaMode';
import { OpenViduRole } from './OpenViduRole';
import { RecordingLayout } from './RecordingLayout';
import { RecordingMode } from './RecordingMode';
import { SessionProperties } from './SessionProperties';
import { TokenOptions } from './TokenOptions';
declare const Buffer;
declare const require;
let https = require('https');
const https = require('https');
export class Session {
private static readonly API_SESSIONS: string = '/api/sessions';
private static readonly API_TOKENS: string = '/api/tokens';
private static readonly API_SESSIONS = '/api/sessions';
private static readonly API_TOKENS = '/api/tokens';
private sessionId: string = "";
private sessionId = '';
private properties: SessionProperties;
constructor(private hostname: string, private port: number, private basicAuth: string, properties?: SessionProperties) {
if (properties == null) {
this.properties = new SessionProperties.Builder().build();
if (properties === null) {
this.properties = {};
} else {
this.properties = properties;
}
@ -47,14 +50,14 @@ export class Session {
resolve(this.sessionId);
}
let requestBody = JSON.stringify({
'mediaMode': this.properties.mediaMode(),
'recordingMode': this.properties.recordingMode(),
'defaultRecordingLayout': this.properties.defaultRecordingLayout(),
'defaultCustomLayout': this.properties.defaultCustomLayout()
const requestBody = JSON.stringify({
mediaMode: !!this.properties.mediaMode ? this.properties.mediaMode : MediaMode.ROUTED,
recordingMode: !!this.properties.recordingMode ? this.properties.recordingMode : RecordingMode.MANUAL,
defaultRecordingLayout: !!this.properties.defaultRecordingLayout ? this.properties.defaultRecordingLayout : RecordingLayout.BEST_FIT,
defaultCustomLayout: !!this.properties.defaultCustomLayout ? this.properties.defaultCustomLayout : ''
});
let options = {
const options = {
hostname: this.hostname,
port: this.port,
path: Session.API_SESSIONS,
@ -64,7 +67,8 @@ export class Session {
'Content-Type': 'application/json',
'Content-Length': Buffer.byteLength(requestBody)
}
}
};
const req = https.request(options, (res) => {
let body = '';
res.on('data', (d) => {
@ -74,7 +78,7 @@ export class Session {
res.on('end', () => {
if (res.statusCode === 200) {
// SUCCESS response from openvidu-server. Resolve sessionId
let parsed = JSON.parse(body);
const parsed = JSON.parse(body);
this.sessionId = parsed.id;
resolve(parsed.id);
} else {
@ -95,23 +99,13 @@ export class Session {
public generateToken(tokenOptions?: TokenOptions): Promise<string> {
return new Promise<string>((resolve, reject) => {
let requestBody;
if (!!tokenOptions) {
requestBody = JSON.stringify({
'session': this.sessionId,
'role': tokenOptions.getRole(),
'data': tokenOptions.getData()
const requestBody = JSON.stringify({
session: this.sessionId,
role: !!tokenOptions.role ? tokenOptions.role : OpenViduRole.PUBLISHER,
data: !!tokenOptions.data ? tokenOptions.data : ''
});
} else {
requestBody = JSON.stringify({
'session': this.sessionId,
'role': OpenViduRole.PUBLISHER,
'data': ''
});
}
let options = {
const options = {
hostname: this.hostname,
port: this.port,
path: Session.API_TOKENS,
@ -122,6 +116,7 @@ export class Session {
'Content-Length': Buffer.byteLength(requestBody)
}
};
const req = https.request(options, (res) => {
let body = '';
res.on('data', (d) => {
@ -131,7 +126,7 @@ export class Session {
res.on('end', () => {
if (res.statusCode === 200) {
// SUCCESS response from openvidu-server. Resolve token
let parsed = JSON.parse(body);
const parsed = JSON.parse(body);
resolve(parsed.id);
} else {
// ERROR response from openvidu-server. Resolve HTTP status

View File

@ -15,61 +15,13 @@
*
*/
import { MediaMode } from "./MediaMode";
import { RecordingMode } from "./RecordingMode";
import { RecordingLayout } from "./RecordingLayout";
import { MediaMode } from './MediaMode';
import { RecordingLayout } from './RecordingLayout';
import { RecordingMode } from './RecordingMode';
export class SessionProperties {
constructor(private mediaModeProp: MediaMode, private recordingModeProp: RecordingMode, private defaultRecordingLayoutProp: RecordingLayout, private defaultCustomLayoutProp: string) { }
mediaMode(): string {
return this.mediaModeProp;
}
recordingMode(): RecordingMode {
return this.recordingModeProp;
}
defaultRecordingLayout(): RecordingLayout {
return this.defaultRecordingLayoutProp;
}
defaultCustomLayout(): string {
return this.defaultCustomLayoutProp;
}
}
export namespace SessionProperties {
export class Builder {
private mediaModeProp: MediaMode = MediaMode.ROUTED;
private recordingModeProp: RecordingMode = RecordingMode.MANUAL;
private defaultRecordingLayoutProp: RecordingLayout = RecordingLayout.BEST_FIT;
private defaultCustomLayoutProp: string = '';
build(): SessionProperties {
return new SessionProperties(this.mediaModeProp, this.recordingModeProp, this.defaultRecordingLayoutProp, this.defaultCustomLayoutProp);
}
mediaMode(mediaMode: MediaMode): Builder {
this.mediaModeProp = mediaMode;
return this;
}
recordingMode(recordingMode: RecordingMode): Builder {
this.recordingModeProp = recordingMode;
return this;
}
defaultRecordingLayout(layout: RecordingLayout): Builder {
this.defaultRecordingLayoutProp = layout;
return this;
}
defaultCustomLayout(path: string): Builder {
this.defaultCustomLayoutProp = path;
return this;
}
};
export interface SessionProperties {
mediaMode?: MediaMode;
recordingMode?: RecordingMode;
defaultRecordingLayout?: RecordingLayout;
defaultCustomLayout?: string;
}

View File

@ -15,40 +15,9 @@
*
*/
import { OpenViduRole } from "./OpenViduRole";
import { OpenViduRole } from './OpenViduRole';
export class TokenOptions {
constructor(private data: string, private role: OpenViduRole) { }
getData(): string {
return this.data;
}
getRole(): OpenViduRole {
return this.role;
}
}
export namespace TokenOptions {
export class Builder {
private dataProp: string = '';
private roleProp: OpenViduRole = OpenViduRole.PUBLISHER;
build(): TokenOptions {
return new TokenOptions(this.dataProp, this.roleProp);
}
data(data: string): Builder {
this.dataProp = data;
return this;
}
role(role: OpenViduRole): Builder {
this.roleProp = role;
return this;
}
};
export interface TokenOptions {
data: string;
role: OpenViduRole;
}