Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: convert js to ts #6

Merged
merged 6 commits into from
Jan 20, 2020
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
8 changes: 7 additions & 1 deletion src/Verto/ConfMan.js → src/Verto/ConfMan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ let CONFMAN_SERNO = 0;
* @hidden
*/
export default class VertoConfMan {
public params: any;
public verto: any;
public serno: any;
public canvasCount: any;
public destroyed: any;

constructor(verto, params) {
this.params = Object.assign(
{
Expand Down Expand Up @@ -101,7 +107,7 @@ export default class VertoConfMan {
// if (this.params.laData.role === "moderator")
}

modCommand(cmd, id, value) {
modCommand(cmd, id, value?) {
this.verto.call('verto.broadcast', {
eventChannel: this.params.laData.modChannel,
data: {
Expand Down
34 changes: 29 additions & 5 deletions src/Verto/Dialog.js → src/Verto/Dialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,30 @@ import Enum from './Enum';
* @hidden
*/
export default class VertoDialog {
public params: any;
public verto: any;
public direction: any;
public lastState: any;
public state: any;
public callbacks: any;
public answered: any;
public attach: any;
public screenShare: any;
public useCamera: any;
public useMic: any;
public useSpeak: any;
public onStateChange: any;
public rtc: any;
public callID: any;
public audioStream: any;
public videoStream: any;
public localVideo: any;
public setAudioPlaybackDevice: any;
public causeCode: any;
public cause: any;
public gotAnswer: any;
public gotEarly: any;

constructor(direction, verto, params) {
this.params = Object.assign(
{
Expand Down Expand Up @@ -92,7 +116,7 @@ export default class VertoDialog {

this.verto.dialogs[this.callID] = this;

const RTCcallbacks = {};
const RTCcallbacks: any = {};

if (this.direction == Enum.direction.inbound) {
if (this.params.display_direction === 'outbound') {
Expand Down Expand Up @@ -272,7 +296,7 @@ export default class VertoDialog {
}
})
.catch((error) => {
const errorMessage = error;
let errorMessage = error;
if (error.name === 'SecurityError') {
errorMessage =
'Dialog: ' +
Expand Down Expand Up @@ -438,7 +462,7 @@ export default class VertoDialog {
}
}

hangup(params) {
hangup(params?) {
if (params) {
if (params.causeCode) {
this.causeCode = params.causeCode;
Expand Down Expand Up @@ -541,7 +565,7 @@ export default class VertoDialog {
}

rtt(obj) {
const pobj = {};
const pobj: any = {};

if (!obj) {
return false;
Expand Down Expand Up @@ -615,7 +639,7 @@ export default class VertoDialog {
return true;
}

answer(params) {
answer(params?) {
if (this.answered) return;

if (!params) params = {};
Expand Down
69 changes: 42 additions & 27 deletions src/Verto/LiveArray.js → src/Verto/LiveArray.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,20 @@
* @hidden
*/
export default class VertoHashArray {
public hash: any;
public array: any;

constructor() {
this.hash = {};
this.array = [];
}

reorder(a) {
reorder(a, arg?) {
this.array = a;
let h = this.hash;
this.hash = {};

const len = array.length;
const len = this.array.length;

for (let i = 0; i < len; i++) {
const key = this.array[i];
Expand All @@ -63,7 +66,7 @@ export default class VertoHashArray {
this.array = [];
}

add(name, val, insertAt) {
add(name, val, insertAt, arg?): any {
let redraw = false;

if (!this.hash[name]) {
Expand All @@ -75,7 +78,7 @@ export default class VertoHashArray {
this.array.push(name);
} else {
let x = 0;
const n = [];
let n = [];
const len = this.array.length;

for (let i = 0; i < len; i++) {
Expand All @@ -97,7 +100,7 @@ export default class VertoHashArray {
return redraw;
}

del(name) {
del(name, arg1?, arg2?): any {
let r = false;

if (this.hash[name]) {
Expand All @@ -119,10 +122,6 @@ export default class VertoHashArray {
return this.array;
}

hash() {
return this.hash;
}

indexOf(name) {
return this.array.indexOf(name);
}
Expand Down Expand Up @@ -155,14 +154,14 @@ export default class VertoHashArray {
dump(html) {
let str = '';

vha.each((name, val) => {
str +=
'name: ' +
name +
'val: ' +
JSON.stringify(val) +
(html ? '<br>' : '\n');
});
// vha.each((name, val) => {
// str +=
// 'name: ' +
// name +
// 'val: ' +
// JSON.stringify(val) +
// (html ? '<br>' : '\n');
// });

return str;
}
Expand All @@ -172,6 +171,23 @@ export default class VertoHashArray {
* @hidden
*/
export class VertoLiveArray extends VertoHashArray {
public verto: any;
public lastSerno: any;
public binding: any;
public user_obj: any;
public config: any;
public local: any;
public _add: any;
public _del: any;
public _reorder: any;
public _clear: any;
public context: any;
public name: any;
public errs: any;
public onChange: any;
public onErr: any;
public hb_pid: any;

constructor(verto, context, name, config) {
super();
this.verto = verto;
Expand All @@ -197,7 +213,6 @@ export class VertoLiveArray extends VertoHashArray {
this.binding = verto.subscribe(context, {
handler: this.eventHandler.bind(this),
userData: verto,
userData: this,
subParams: config.subParams,
});
}
Expand Down Expand Up @@ -228,7 +243,7 @@ export class VertoLiveArray extends VertoHashArray {

if (this.lastSerno > 0 && serno != this.lastSerno + 1) {
if (this.onErr) {
this.onErr(la, {
this.onErr(this, {
lastSerno: this.lastSerno,
serno: serno,
});
Expand Down Expand Up @@ -262,8 +277,8 @@ export class VertoLiveArray extends VertoHashArray {
key = serno;
}
if (this.checkSerno(serno)) {
if (la.onChange) {
la.onChange(la, {
if (this.onChange) {
this.onChange(this, {
serno: serno,
action: 'init',
index: index,
Expand Down Expand Up @@ -292,9 +307,9 @@ export class VertoLiveArray extends VertoHashArray {
}
}

// // @param serno La is the serial number for la particular request.
// // @param key If looking at it as a hash table, la represents the key in the hashArray object where you want to store the val object.
// // @param index If looking at it as an array, la represents the position in the array where you want to store the val object.
// // @param serno This is the serial number for this particular request.
// // @param key If looking at it as a hash table, this represents the key in the hashArray object where you want to store the val object.
// // @param index If looking at it as an array, this represents the position in the array where you want to store the val object.
// // @param val La is the object you want to store at the key or index location in the hash table / array.
add(serno, val, key, index) {
if (key === null || key === undefined) {
Expand Down Expand Up @@ -354,7 +369,7 @@ export class VertoLiveArray extends VertoHashArray {
}
}

eventHandler(v, e, la) {
eventHandler(v, e?, la?) {
const packet = e.data;

console.debug('READ:', packet);
Expand Down Expand Up @@ -453,8 +468,8 @@ export class VertoLiveArray extends VertoHashArray {
this.broadcast(this.context, {
liveArray: {
command: 'changepage',
context: la.context,
name: la.name,
context: this.context,
name: this.name,
obj: obj,
},
});
Expand Down
Loading