Skip to content

Commit

Permalink
refactor: general refactor into controllers folder
Browse files Browse the repository at this point in the history
  • Loading branch information
airscripts committed Jan 21, 2023
1 parent 7d7ec31 commit 4a20441
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 35 deletions.
35 changes: 3 additions & 32 deletions controllers/call.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,15 @@ import stack from "./stack.js";

class Call {
session = null;
calledInput = document.getElementById("called-input");
callText = document.getElementById("call-text");
callButton = document.getElementById("call-button");
hangUpButton = document.getElementById("hang-up-button");
calledInput = document.getElementById("called-input");
audioRemote = document.getElementById("audio-remote");
// holdButton = document.getElementById("hold-button");
// resumeButton = document.getElementById("resume-button");
hangUpButton = document.getElementById("hang-up-button");

eventListener = (event) => {
console.log(event);
switch (event.type) {
// case "m_local_hold_ok":
// this.holdButton.removeEventListener("click", this.holdCall);
// this.holdButton.disabled = true;

// this.resumeButton.addEventListener("click", this.resumeCall);
// this.resumeButton.disabled = false;
// break;

// case "m_local_resume_ok":
// this.resumeButton.removeEventListener("click", this.resumeCall);
// this.resumeButton.disabled = true;
// break;

case "connecting":
this.callText.textContent = event.description;
break;
Expand All @@ -40,13 +25,6 @@ class Call {
case "terminated":
this.hangUpButton.removeEventListener("click", this.hangUp);
this.hangUpButton.disabled = true;

// this.holdButton.removeEventListener("click", this.holdCall);
// this.holdButton.disabled = true;

// this.resumeButton.removeEventListener("click", this.resumeCall);
// this.resumeButton.disabled = true;

this.callText.textContent = "";
this.calledInput.value = null;
this.callButton.disabled = false;
Expand All @@ -63,6 +41,7 @@ class Call {

this.session = stack.sip.newSession("call-audio", {
audio_remote: this.audioRemote,

events_listener: {
events: "*",
listener: this.eventListener,
Expand All @@ -79,14 +58,6 @@ class Call {
hangUp = () => {
this.session.hangup();
}

// holdCall = () => {
// this.session.hold();
// }

// resumeCall = () => {
// this.session.resume();
// }
}

let call = new Call();
Expand Down
1 change: 0 additions & 1 deletion controllers/register.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ class Register {

if (isReadToCall) {
let callButton = document.getElementById("call-button");

callButton.addEventListener("click", call.makeCall);
callButton.disabled = false;
}
Expand Down
5 changes: 3 additions & 2 deletions controllers/stack.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@ class Stack {
let conf = configs.sip;

this.sip = new SIPml.Stack({
realm: conf.realm,
impi: conf.impi,
impu: conf.impu,
realm: conf.realm,
password: conf.password,
ice_servers: conf.ice_servers,
display_name: conf.display_name,
websocket_proxy_url: conf.websocket_proxy_url,
ice_servers: conf.ice_servers,
enable_rtcweb_breaker: conf.enable_rtcweb_breaker,

events_listener: {
events: "*",
listener: this.eventListener,
Expand Down

0 comments on commit 4a20441

Please sign in to comment.