Merge branch 'feature-raise-hand' into develop

This commit is contained in:
Stefan Otto
2018-04-24 11:08:41 +02:00
15 changed files with 273 additions and 10 deletions
+48
View File
@@ -587,6 +587,43 @@ export default class RoomClient
});
}
sendRaiseHandState(state)
{
logger.debug('sendRaiseHandState: ', state);
this._dispatch(
stateActions.setMyRaiseHandStateInProgress(true));
return this._protoo.send('raisehand-message', { raiseHandState: state })
.then(() =>
{
this._dispatch(
stateActions.setMyRaiseHandState(state));
this._dispatch(requestActions.notify(
{
text : 'raiseHand state changed'
}));
this._dispatch(
stateActions.setMyRaiseHandStateInProgress(false));
})
.catch((error) =>
{
logger.error('sendRaiseHandState() | failed: %o', error);
this._dispatch(requestActions.notify(
{
type : 'error',
text : `Could not change raise hand state: ${error}`
}));
// We need to refresh the component for it to render changed state
this._dispatch(stateActions.setMyRaiseHandState(!state));
this._dispatch(
stateActions.setMyRaiseHandStateInProgress(false));
});
}
restartIce()
{
logger.debug('restartIce()');
@@ -713,6 +750,17 @@ export default class RoomClient
break;
}
case 'raisehand-message':
{
accept();
const { peerName, raiseHandState } = request.data;
logger.debug('Got raiseHandState from "%s"', peerName);
this._dispatch(
stateActions.setPeerRaiseHandState(peerName, raiseHandState));
break;
}
case 'chat-message-receive':
{
+4
View File
@@ -59,6 +59,10 @@ const Peer = (props) =>
return (
<div data-component='Peer'>
<div className='indicators'>
{peer.raiseHandState ?
<div className='icon raise-hand' />
:null
}
{!micEnabled ?
<div className='icon mic-off' />
:null
+23 -4
View File
@@ -24,10 +24,11 @@ class Room extends React.Component
onRoomLinkCopy,
onSetAudioMode,
onRestartIce,
onLeaveMeeting,
onShareScreen,
onUnShareScreen,
onNeedExtension
onNeedExtension,
onToggleHand,
onLeaveMeeting
} = this.props;
let screenState;
@@ -157,6 +158,16 @@ class Room extends React.Component
onClick={() => onRestartIce()}
/>
<div
className={classnames('button', 'raise-hand', {
on : me.raiseHand,
disabled : me.raiseHandInProgress
})}
data-tip='Raise hand'
data-type='dark'
onClick={() => onToggleHand(!me.raiseHand)}
/>
<div
className={classnames('button', 'leave-meeting')}
data-tip='Leave meeting'
@@ -185,10 +196,11 @@ Room.propTypes =
onRoomLinkCopy : PropTypes.func.isRequired,
onSetAudioMode : PropTypes.func.isRequired,
onRestartIce : PropTypes.func.isRequired,
onLeaveMeeting : PropTypes.func.isRequired,
onShareScreen : PropTypes.func.isRequired,
onUnShareScreen : PropTypes.func.isRequired,
onNeedExtension : PropTypes.func.isRequired
onNeedExtension : PropTypes.func.isRequired,
onToggleHand : PropTypes.func.isRequired,
onLeaveMeeting : PropTypes.func.isRequired
};
const mapStateToProps = (state) =>
@@ -226,6 +238,13 @@ const mapDispatchToProps = (dispatch) =>
{
dispatch(requestActions.restartIce());
},
onToggleHand : (enable) =>
{
if (enable)
dispatch(requestActions.raiseHand());
else
dispatch(requestActions.lowerHand());
},
onLeaveMeeting : () =>
{
dispatch(requestActions.leaveRoom());
+5 -4
View File
@@ -51,10 +51,11 @@
{
'alice' :
{
name : 'alice',
displayName : 'Alice Thomsom',
device : { flag: 'chrome', name: 'Chrome', version: '58' },
consumers : [ 5551, 5552 ]
name : 'alice',
displayName : 'Alice Thomsom',
raiseHandState : false,
device : { flag: 'chrome', name: 'Chrome', version: '58' },
consumers : [ 5551, 5552 ]
}
},
consumers :
+18 -2
View File
@@ -13,6 +13,8 @@ const initialState =
screenShareInProgress : false,
audioOnly : false,
audioOnlyInProgress : false,
raiseHand : false,
raiseHandInProgress : false,
restartIceInProgress : false
};
@@ -33,11 +35,11 @@ const me = (state = initialState, action) =>
return { ...state, canSendMic, canSendWebcam };
}
case 'SET_SCREEN_CAPABILITIES':
{
const { canShareScreen, needExtension } = action.payload;
return { ...state, canShareScreen, needExtension };
}
@@ -87,6 +89,20 @@ const me = (state = initialState, action) =>
return { ...state, audioOnlyInProgress: flag };
}
case 'SET_MY_RAISE_HAND_STATE':
{
const { flag } = action.payload;
return { ...state, raiseHand: flag };
}
case 'SET_MY_RAISE_HAND_STATE_IN_PROGRESS':
{
const { flag } = action.payload;
return { ...state, raiseHandInProgress: flag };
}
case 'SET_RESTART_ICE_IN_PROGRESS':
{
const { flag } = action.payload;
+13
View File
@@ -34,6 +34,19 @@ const peers = (state = initialState, action) =>
return { ...state, [newPeer.name]: newPeer };
}
case 'SET_PEER_RAISE_HAND_STATE':
{
const { peerName, raiseHandState } = action.payload;
const peer = state[peerName];
if (!peer)
throw new Error('no Peer found');
const newPeer = { ...peer, raiseHandState };
return { ...state, [newPeer.name]: newPeer };
}
case 'ADD_CONSUMER':
{
const { consumer, peerName } = action.payload;
+14
View File
@@ -78,6 +78,20 @@ export const disableAudioOnly = () =>
};
};
export const raiseHand = () =>
{
return {
type : 'RAISE_HAND'
};
};
export const lowerHand = () =>
{
return {
type : 'LOWER_HAND'
};
};
export const restartIce = () =>
{
return {
+14
View File
@@ -102,6 +102,20 @@ export default ({ dispatch, getState }) => (next) =>
break;
}
case 'RAISE_HAND':
{
client.sendRaiseHandState(true);
break;
}
case 'LOWER_HAND':
{
client.sendRaiseHandState(false);
break;
}
case 'RESTART_ICE':
{
client.restartIce();
+24
View File
@@ -86,6 +86,30 @@ export const setAudioOnlyInProgress = (flag) =>
};
};
export const setMyRaiseHandState = (flag) =>
{
return {
type : 'SET_MY_RAISE_HAND_STATE',
payload : { flag }
};
};
export const setMyRaiseHandStateInProgress = (flag) =>
{
return {
type : 'SET_MY_RAISE_HAND_STATE_IN_PROGRESS',
payload : { flag }
};
};
export const setPeerRaiseHandState = (peerName, raiseHandState) =>
{
return {
type : 'SET_PEER_RAISE_HAND_STATE',
payload : { peerName, raiseHandState }
};
};
export const setRestartIceInProgress = (flag) =>
{
return {