adding button in contact for calling

This commit is contained in:
Roland Osborne 2023-03-29 23:57:39 -07:00
parent 8b36cd0c2a
commit 3ff5ac6f14
3 changed files with 11 additions and 11 deletions

View File

@ -33,11 +33,6 @@ export function useRingContext() {
const audioTrack = useRef();
const iceServers = [
{
urls: 'stun:35.165.123.117:5001?transport=udp',
username: 'user',
credential: 'pass'
},
{
urls: 'turn:35.165.123.117:5001?transport=udp',
username: 'user',
@ -174,6 +169,7 @@ export function useRingContext() {
ws.current.close();
}
else if (signal.description) {
console.log("NULL STREAM");
stream.current = null;
if (signal.description.type === 'offer' && pc.current.signalingState !== 'stable') {
return; //rudely ignore
@ -295,6 +291,7 @@ export function useRingContext() {
pc.current.ontrack = (ev) => { //{streams: [stream]}) => {
console.log("ADD TRACK", ev);
if (!stream.current) {
console.log("NEW MEDIA!");
stream.current = new MediaStream();
updateState({ remoteStream: stream.current });
}
@ -361,6 +358,8 @@ export function useRingContext() {
}
}
else if (signal.description) {
console.log("NEW DESCRIPTION");
stream.current = null;
if (signal.description.type === 'offer' && pc.current.signalingState !== 'stable') {
await pc.current.setLocalDescription({ type: "rollback" });
}

View File

@ -80,12 +80,18 @@ export function Session() {
setCallHeight(height);
setCallWidth(videoWidth * (height / videoHeight));
}
else if (videoHeight < 256 || videoWidth < 256) {
setCallHeight(256);
setCallWidth(256);
}
else {
setCallHeight(videoHeight);
setCallWidth(videoWidth);
}
};
console.log(" SET REMOTE STREAM");
remote.current.srcObject = state.remoteStream;
remote.current.load();
remote.current.play();
}
else {

View File

@ -9,10 +9,6 @@ export function Contact({ close, guid, listing }) {
const [ modal, modalContext ] = Modal.useModal();
const { state, actions } = useContact(guid, listing, close);
const ring = async () => {
actions.ring();
};
const updateContact = async (action) => {
try {
await action();
@ -98,6 +94,7 @@ export function Contact({ close, guid, listing }) {
<div className="controls">
<div className={ state.buttonStatus } onClick={() => updateContact(actions.disconnect)}>Disconnect</div>
<div className={ state.buttonStatus } onClick={() => updateContact(actions.disconnectRemove)}>Delete Contact</div>
<div className={ state.buttonStatus } onClick={actions.ring}>Call Contact</div>
</div>
)}
@ -137,8 +134,6 @@ export function Contact({ close, guid, listing }) {
</div>
)}
<div className={ state.buttonStatus } onClick={ring}>RING</div>
</div>
</div>