soft-phone
Version:
178 lines • 9.48 kB
JavaScript
import { Component } from '@angular/core';
import "../SIPml.js";
import { PhoneService } from '../../../service/index';
import { CallState, User } from '../../index';
var ExpertComponent = /** @class */ (function () {
function ExpertComponent(service) {
this.service = service;
}
ExpertComponent.prototype.ngOnInit = function () {
var _this = this;
this.service.reg.bandwidth = 0;
this.service.reg.enable_rtcweb_breaker = false;
this.service.reg.disable_callbtn_options = true;
this.service.reg.disable_video = true;
this.service.reg.display_name = "104";
this.service.reg.impi = "104";
this.service.reg.impu = "sip:104@192.168.1.2";
this.service.reg.password = "xputer";
this.service.reg.realm = "192.168.1.2";
this.service.reg.enable_early_ims = true;
this.service.reg.enable_media_stream_cache = true;
this.service.reg.ice_servers = [];
this.service.reg.websocket_proxy_url = "ws://192.168.1.2:8088/ws";
this.service.reg.outbound_proxy_url = "udp://192.168.1.2:5060";
this.service.reg.video_size = { minWidth: 640, minHeight: 480, maxWidth: 640, maxHeight: 480 };
this.service.reg.disable_debug = true;
this.service.reg.type = null;
this.service.reg.auto_recording = false;
SIPml.init();
this.service.configCall = {
audio_remote: document.getElementById('audio-remote'),
//screencast_window_id: 0x00000000, // entire desktop
bandwidth: { audio: undefined, video: undefined },
//video_size: this.service.reg.video_size,
events_listener: {
events: '*', listener: function (e) {
_this.service.onSipEventSession(e);
}
},
sip_caps: [
{ name: '+g.oma.sip-im' },
{ name: 'language', value: '\"en,fr\"' }
]
};
};
ExpertComponent.prototype.login = function () {
var me = this.service;
var you = this;
var eventsListener = function (e) {
console.info('session event = ' + e.type);
me.txtRegStatus = e.type;
if (e.type == 'connected' && e.session == me.registerSession) {
me.txtRegStatus = "connected as " + me.reg.impi;
you.makeCall();
// sendMessage();
// publishPresence();
// subscribePresence('johndoe'); // watch johndoe's presence status change
}
};
me.registerSession = this.service.sipStack.newSession('register', {
events_listener: { events: '*', listener: eventsListener } // optional: '*' means all events
});
me.registerSession.register();
};
ExpertComponent.prototype.eventsListenerLogin = function (e) {
var me = this;
var you = this.service;
switch (e.type) {
case 'started':
me.login();
// try {
// // LogIn (REGISTER) as soon as the stack finish starting
// you.registerSession = this.newSession('register', {
// expires: 200,
// events_listener: { events: '*', listener: you.onSipEventSession },
// sip_caps: [
// { name: '+g.oma.sip-im', value: null },
// //{ name: '+sip.ice' }, // rfc5768: FIXME doesn't work with Polycom TelePresence
// { name: '+audio', value: null },
// { name: 'language', value: '\"en,fr\"' }
// ]
// });
// you.registerSession.register();
// }
// catch (e) {
// you.txtRegStatus = ""+e ;
// }
break;
case 'i_new_message':
break;
case 'i_new_call':
you.callSession = e.newSession;
you.callSession.setConfiguration(you.configCall);
you.startRingTone();
var sRemoteNumber = (me.service.callSession.getRemoteFriendlyName() || 'unknown');
you.status = CallState.ActiveCallInbound;
//if user does not exist
you.selectedUser = new User();
you.selectedUser.phoneNumber = sRemoteNumber;
you.selectedUser.fullname = sRemoteNumber;
break;
case 'stopping':
case 'stopped':
case 'failed_to_start':
case 'failed_to_stop':
{
var bFailure = (e.type == 'failed_to_start') || (e.type == 'failed_to_stop');
you.sipStack = null;
you.registerSession = null;
you.callSession = null;
you.stopRingbackTone();
you.stopRingTone();
you.callStat = '';
you.txtRegStatus = bFailure ? "Disconnected: " + e.description : "Disconnected";
break;
}
default:
break;
}
};
ExpertComponent.prototype.makeCall = function () {
var me = this.service;
var you = this;
this.service.callSession = this.service.sipStack.newSession(me.call_type, me.configCall);
};
ExpertComponent.prototype.sipRegister = function () {
var me = this;
var you = this.service;
if (this.service.sipStack) {
this.service.sipStack.stop(); // shutdown all sessions
this.service.sipStack = null;
this.service.callSession = null;
this.service.registerSession = null;
}
else {
var me = this;
this.service.sipStack = new SIPml.Stack({
realm: this.service.reg.realm,
impi: this.service.reg.impi,
impu: this.service.reg.impu,
password: this.service.reg.password,
display_name: this.service.reg.display_name,
websocket_proxy_url: this.service.reg.websocket_proxy_url,
outbound_proxy_url: this.service.reg.outbound_proxy_url,
ice_servers: this.service.reg.ice_servers,
enable_rtcweb_breaker: this.service.reg.enable_rtcweb_breaker,
events_listener: {
events: '*', listener: function (e) {
me.eventsListenerLogin(e);
}
},
enable_early_ims: this.service.reg.enable_early_ims,
enable_media_stream_cache: this.service.reg.enable_media_stream_cache,
bandwidth: null,
video_size: this.service.reg.video_size,
sip_headers: [
{ name: 'User-Agent', value: 'IM-client/OMA1.0 sipML5-v1.2016.03.04' },
{ name: 'Organization', value: 'Doubango Telecom' }
]
});
this.service.sipStack.start();
}
};
ExpertComponent.decorators = [
{ type: Component, args: [{
selector: 'expert',
template: "\n <button class=\"btnFx\" pButton type=\"button\" pTooltip=\"{{service.txtRegStatus}}\" (click)=\"sipRegister()\" >\n <span class=\"verticalCenter\" *ngIf=\"service.txtRegStatus.startsWith('connected')\" class=\"material-icons ui-icon-radio-button-unchecked item-icon\" style=\"font-size:20px; color: green \" ></span>\n <span class=\"verticalCenter\" *ngIf=\"service.txtRegStatus === 'Disconnected'\" class=\"material-icons ui-icon-radio-button-unchecked item-icon\" style=\"font-size:20px; color: #ffc200 \" ></span>\n <span class=\"verticalCenter\" *ngIf=\"service.txtRegStatus.startsWith('Disconnected:') \" class=\"material-icons ui-icon-radio-button-unchecked item-icon\" style=\"font-size:20px; color: red \" ></span>\n </button>\n ",
styles: ["\n #panel{width:450px;margin:0 auto}#panel-heada{text-align:center}.Caller-details{text-align:center}.Call-button{text-align:center}#btn{width:250px}.fone{text-align:center}body #kpp .ui-button{width:280px;height:40px}body #kp .ui-button{width:80px;height:80px;float:none}.butgrp{padding-bottom:0px}.nopad{padding:0px}.short{height:184px;max-height:184px;overflow-y:auto;overflow-x:hidden;width:280px}.phone-width{width:290px}.expand{min-height:184px;max-height:395px;overflow-x:hidden;overflow-y:auto}.full-width{width:100%}body .md-inputfield{margin-bottom:5px}.c-input span input{width:100% !important}.recip{width:280px;height:60px;margin:0px}.btnFx{width:20px !important;height:20px !important;padding:0px !important;line-height:0em !important}.verticalCenter{vertical-align:middle;margin:0px}\n "]
},] },
];
/** @nocollapse */
ExpertComponent.ctorParameters = function () { return [
{ type: PhoneService, },
]; };
return ExpertComponent;
}());
export { ExpertComponent };
//# sourceMappingURL=expert.component.js.map