From 56d6075d38772ffaf4f8c5656344f37ed77196dc Mon Sep 17 00:00:00 2001 From: admin Date: Mon, 4 May 2020 21:14:28 +0300 Subject: [PATCH] Initial Commit --- README.md | 42 ++++++++++++++++++++++++++++++++++++------ src/index.js | 32 +++++++++++++++++--------------- 2 files changed, 53 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index a877e9d7..2f57a553 100644 --- a/README.md +++ b/README.md @@ -13,16 +13,46 @@ npm install --save react-softphone ## Usage ```jsx -import React, { Component } from 'react' - +import React from 'react' import { SoftPhone } from 'react-softphone' +import { WebSocketInterface } from 'jssip'; + + const config = { + domain: 'sip-server@your-domain.io', // sip-server@your-domain.io + uri: 'sip:sip-user@your-domain.io', // sip:sip-user@your-domain.io + password: 'secret', // PASSWORD , + ws_servers: 'wss://sip-user@your-domain.io:8089/ws', //ws server + sockets: new WebSocketInterface('wss://sip-server@your-domain.io:8089/ws'), + display_name: '***',//jssip Display Name + debug: false // Turn debug messages on + + }; +const setConnectOnStartToLocalStorage =(newValue)=>{ + + +//Save newValue of connect on start to local storage -const Example = () => { - const example = SoftPhone() +return true +} + +function App() { return ( -
{example}
- ) +
+
+ +
+
+ ); } + +export default App; + ``` ## License diff --git a/src/index.js b/src/index.js index 79a78aae..c7b64f67 100644 --- a/src/index.js +++ b/src/index.js @@ -91,11 +91,9 @@ const useStyles = makeStyles((theme) => ({ })); -export function useLeet( ) { - return 33 -} -export function SoftPhone({ - callVolume=20, ringVolume, setConnectOnStartToLocalStorage, connectOnStart, config + +export default function SoftPhone({ + callVolume, ringVolume, setConnectOnStartToLocalStorage, connectOnStart=false, config }) { const defaultSoftPhoneState = { displayCalls: [ @@ -177,7 +175,6 @@ export function SoftPhone({ }; const classes = useStyles(); - const [drawerOpen, drawerSetOpen] = useState(true); const [dialState, setdialState] = useState(''); const [activeChannel, setActiveChannel] = useState(0); @@ -573,15 +570,20 @@ export function SoftPhone({ if (localStatePhone.phoneConnectOnStart) { handleConnectPhone(null, true); } - player.current.defaultMuted = false; - player.current.autoplay = true; - player.current.volume = parseInt(localStatePhone.callVolume, 10) / 100; - // player.volume = this.outputVolume; - flowRoute.player = player; - ringer.current.src = '/sound/ringing.mp3'; - ringer.current.loop = true; - ringer.current.volume = parseInt(localStatePhone.ringVolume, 10) / 100; - flowRoute.ringer = ringer; + + try { + player.current.defaultMuted = false; + player.current.autoplay = true; + player.current.volume = parseInt(localStatePhone.callVolume, 10) / 100; + // player.volume = this.outputVolume; + flowRoute.player = player; + ringer.current.src = '/sound/ringing.mp3'; + ringer.current.loop = true; + ringer.current.volume = parseInt(localStatePhone.ringVolume, 10) / 100; + flowRoute.ringer = ringer; + }catch (e) { + + } }, []);