Skip to content

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
admin authored and admin committed May 4, 2020
1 parent 34b9130 commit 56d6075
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 21 deletions.
42 changes: 36 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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: '[email protected]', // [email protected]
uri: 'sip:[email protected]', // sip:[email protected]
password: 'secret', // PASSWORD ,
ws_servers: 'wss://[email protected]:8089/ws', //ws server
sockets: new WebSocketInterface('wss://[email protected]: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 (
<div>{example}</div>
)
<div className="App">
<header className="App-header">
<SoftPhone
callVolume={33} //Set Default callVolume
ringVolume={44} //Set Default ringVolume
connectOnStart={false} //Auto connect to sip
config={config} //Voip config
setConnectOnStartToLocalStorage={setConnectOnStartToLocalStorage} // Callback function
/>
</header>
</div>
);
}

export default App;

```

## License
Expand Down
32 changes: 17 additions & 15 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand Down Expand Up @@ -177,7 +175,6 @@ export function SoftPhone({
};
const classes = useStyles();


const [drawerOpen, drawerSetOpen] = useState(true);
const [dialState, setdialState] = useState('');
const [activeChannel, setActiveChannel] = useState(0);
Expand Down Expand Up @@ -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) {

}
},
[]);

Expand Down

0 comments on commit 56d6075

Please sign in to comment.