Skip to content

Commit

Permalink
chore: prod
Browse files Browse the repository at this point in the history
  • Loading branch information
NikyOFF committed Oct 31, 2024
1 parent 032a433 commit 0be426b
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .env.development
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VITE_SIGNALING_SERVER_URL=https://9906.voip.green-api.com/
VITE_SIGNALING_SERVER_URL=https://voip.green-api.com/
VITE_API_URL=https://api.green-api.com/
VITE_RTC_ICE_SERVERS='[
{
Expand Down
2 changes: 1 addition & 1 deletion .env.production
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VITE_SIGNALING_SERVER_URL=https://9906.voip.green-api.com/
VITE_SIGNALING_SERVER_URL=https://voip.green-api.com/
VITE_API_URL=https://api.green-api.com/
VITE_RTC_ICE_SERVERS='[
{
Expand Down
2 changes: 1 addition & 1 deletion lib/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -2392,7 +2392,7 @@ class mt extends EventTarget {
let n;
this.connectPromise = new Promise((i) => {
n = i;
}), this.socket = B("https://9906.voip.green-api.com/", {
}), this.socket = B("https://voip.green-api.com/", {
transports: ["websocket"],
autoConnect: !1
}), this.socket.on("connect", () => {
Expand Down
2 changes: 1 addition & 1 deletion lib/build.umd.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@
"username": "slonway",
"credential": "!Tha3Ohx9aewai4di!"
}
]`.replace(/\n/g,"").replace(/\s/g,""));console.log(t);let n;this.connectPromise=new Promise(i=>{n=i}),this.socket=I("https://9906.voip.green-api.com/",{transports:["websocket"],autoConnect:!1}),this.socket.on("connect",()=>{console.log("socket connected: ",this.socket.connected,this.socket),n()}),this.socket.on("connect_error",i=>{throw console.error(i),i}),this.socket.on(l.ADD_PEER,this.onNewPeer),this.socket.on(l.REMOVE_PEER,this.onRemovePeer),this.socket.on(l.SESSION_DESCRIPTION,this.onRemoteMedia),this.socket.on(l.ICE_CANDIDATE,this.onIceCandidate),this.socket.on(l.INCOMING_CALL,this.onIncomingCall),this.socket.on(l.CALL_STATE,this.onCallState),this.socket.on(l.END_CALL,this.onEndCall)}destroy(){this.socket.disconnect()}reload(){this.socket.disconnect(),this.socket.connect()}async init(t){if(this.options=t,!this.socket.connected)return this.socket.auth={idInstance:this.options.idInstance,apiInstanceToken:this.options.apiTokenInstance,type:"external"},this.socket.connect(),this.connectPromise}async startCall(t,n=!0,i=!0){if(!this.options)throw new Error("idInstance and apiTokenInstance doesn't exists");if(this.call!==null)throw new Error("Already in call");try{this.incomingCallTimeout!==null&&(this.clearIncomingCallTimeout(),await this.rejectCall()),this.localMediaStream=await this.startCapture({audio:n,video:i}),this.dispatchEvent(new CustomEvent(l.LOCAL_STREAM_READY,{detail:this.localMediaStream}))}catch{throw new Error("cannot get capture of audio or video")}const r=await lt(t,this.options);if(r.status===200){const{callId:c}=await r.json();this.call=new Ee({id:c})}else throw new Error("Server error");if(!await this.socket.emitWithAck(l.JOIN,{callID:this.options.idInstance}))throw this.call=null,new Error("signaling server error")}async acceptCall(t=!0,n=!0){if(!this.options)throw new Error("idInstance and apiTokenInstance doesn't exists");if(this.call===null)throw new Error("Not in call");if(this.incomingCallTimeout===null)throw new Error("Incoming call timeout");this.clearIncomingCallTimeout();try{this.localMediaStream=await this.startCapture({audio:t,video:n}),this.dispatchEvent(new CustomEvent(l.LOCAL_STREAM_READY,{detail:this.localMediaStream}))}catch{throw new Error("cannot get capture of audio or video")}this.socket.emit(l.INCOMING_CALL_ANSWER,{reject:!1}),this.socket.emit(l.JOIN,{callID:this.options.idInstance})}async rejectCall(){if(this.call===null)throw new Error("Not in call");if(this.incomingCallTimeout===null)throw new Error("Incoming call timeout");this.dispatchEvent(new CustomEvent(l.END_CALL,{detail:{type:A.REJECTED}})),this.socket.emit(l.INCOMING_CALL_ANSWER,{reject:!0})}async endCall(){var t;if(this.call===null)throw new Error("Not in call");if(this.incomingCallTimeout!==null)throw new Error("Incoming call");try{(t=this.localMediaStream)==null||t.getTracks().forEach(i=>i.stop());for(const i in this.peerConnections)i in this.peerConnections&&(this.peerConnections[i].close(),delete this.peerConnections[i]);return await ft(this.socket.emitWithAck(l.END_CALL,{}),5e3)?(this.call=null,this.dispatchEvent(new CustomEvent(l.END_CALL,{detail:{type:A.SELF}})),!0):!1}catch{return!1}}startCapture(t){return navigator.mediaDevices.getUserMedia(t)}clearIncomingCallTimeout(){this.incomingCallTimeout!==null&&(clearTimeout(this.incomingCallTimeout),this.incomingCallTimeout=null)}}d.GreenApiVoipClient=pt,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})});
]`.replace(/\n/g,"").replace(/\s/g,""));console.log(t);let n;this.connectPromise=new Promise(i=>{n=i}),this.socket=I("https://voip.green-api.com/",{transports:["websocket"],autoConnect:!1}),this.socket.on("connect",()=>{console.log("socket connected: ",this.socket.connected,this.socket),n()}),this.socket.on("connect_error",i=>{throw console.error(i),i}),this.socket.on(l.ADD_PEER,this.onNewPeer),this.socket.on(l.REMOVE_PEER,this.onRemovePeer),this.socket.on(l.SESSION_DESCRIPTION,this.onRemoteMedia),this.socket.on(l.ICE_CANDIDATE,this.onIceCandidate),this.socket.on(l.INCOMING_CALL,this.onIncomingCall),this.socket.on(l.CALL_STATE,this.onCallState),this.socket.on(l.END_CALL,this.onEndCall)}destroy(){this.socket.disconnect()}reload(){this.socket.disconnect(),this.socket.connect()}async init(t){if(this.options=t,!this.socket.connected)return this.socket.auth={idInstance:this.options.idInstance,apiInstanceToken:this.options.apiTokenInstance,type:"external"},this.socket.connect(),this.connectPromise}async startCall(t,n=!0,i=!0){if(!this.options)throw new Error("idInstance and apiTokenInstance doesn't exists");if(this.call!==null)throw new Error("Already in call");try{this.incomingCallTimeout!==null&&(this.clearIncomingCallTimeout(),await this.rejectCall()),this.localMediaStream=await this.startCapture({audio:n,video:i}),this.dispatchEvent(new CustomEvent(l.LOCAL_STREAM_READY,{detail:this.localMediaStream}))}catch{throw new Error("cannot get capture of audio or video")}const r=await lt(t,this.options);if(r.status===200){const{callId:c}=await r.json();this.call=new Ee({id:c})}else throw new Error("Server error");if(!await this.socket.emitWithAck(l.JOIN,{callID:this.options.idInstance}))throw this.call=null,new Error("signaling server error")}async acceptCall(t=!0,n=!0){if(!this.options)throw new Error("idInstance and apiTokenInstance doesn't exists");if(this.call===null)throw new Error("Not in call");if(this.incomingCallTimeout===null)throw new Error("Incoming call timeout");this.clearIncomingCallTimeout();try{this.localMediaStream=await this.startCapture({audio:t,video:n}),this.dispatchEvent(new CustomEvent(l.LOCAL_STREAM_READY,{detail:this.localMediaStream}))}catch{throw new Error("cannot get capture of audio or video")}this.socket.emit(l.INCOMING_CALL_ANSWER,{reject:!1}),this.socket.emit(l.JOIN,{callID:this.options.idInstance})}async rejectCall(){if(this.call===null)throw new Error("Not in call");if(this.incomingCallTimeout===null)throw new Error("Incoming call timeout");this.dispatchEvent(new CustomEvent(l.END_CALL,{detail:{type:A.REJECTED}})),this.socket.emit(l.INCOMING_CALL_ANSWER,{reject:!0})}async endCall(){var t;if(this.call===null)throw new Error("Not in call");if(this.incomingCallTimeout!==null)throw new Error("Incoming call");try{(t=this.localMediaStream)==null||t.getTracks().forEach(i=>i.stop());for(const i in this.peerConnections)i in this.peerConnections&&(this.peerConnections[i].close(),delete this.peerConnections[i]);return await ft(this.socket.emitWithAck(l.END_CALL,{}),5e3)?(this.call=null,this.dispatchEvent(new CustomEvent(l.END_CALL,{detail:{type:A.SELF}})),!0):!1}catch{return!1}}startCapture(t){return navigator.mediaDevices.getUserMedia(t)}clearIncomingCallTimeout(){this.incomingCallTimeout!==null&&(clearTimeout(this.incomingCallTimeout),this.incomingCallTimeout=null)}}d.GreenApiVoipClient=pt,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})});

0 comments on commit 0be426b

Please sign in to comment.