You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

207 lines
4.9 KiB

3 months ago
import React from 'react';
import { connect } from 'react-redux';
import PropTypes from 'prop-types';
import ReactTooltip from 'react-tooltip';
import classnames from 'classnames';
import clipboardCopy from 'clipboard-copy';
import * as appPropTypes from './appPropTypes';
import { withRoomContext } from '../RoomContext';
import * as requestActions from '../redux/requestActions';
import { Appear } from './transitions';
import Me from './Me';
import ChatInput from './ChatInput';
import Peers from './Peers';
import Stats from './Stats';
import Notifications from './Notifications';
import NetworkThrottle from './NetworkThrottle';
class Room extends React.Component
{
render()
{
const {
roomClient,
room,
me,
amActiveSpeaker,
onRoomLinkCopy
} = this.props;
const mediasoupClientVersion = room.mediasoupClientVersion === '__MEDIASOUP_CLIENT_VERSION__'
? 'dev'
: room.mediasoupClientVersion;
return (
<Appear duration={300}>
<div data-component='Room'>
3 months ago
<div className='crumbs'>
<span className='goback' onClick={() => {history.push('/counselling/expertList')}}>
值班专家<span style={{margin: '0 4px'}}>{`>`}</span>
</span>
<span style={{color: '#5F6368'}}>在线聊天</span>
</div>
3 months ago
<Notifications />
3 months ago
{/* 当前房间状态信息 */}
{/* <div className='state'>
3 months ago
<div className={classnames('icon', room.state)} />
<p className={classnames('text', room.state)}>{room.state}</p>
</div>
<div className='info'>
<p className='text'><span className='label'>server:&nbsp;&nbsp;</span>{room.mediasoupVersion}</p>
<p className='text'><span className='label'>client:&nbsp;&nbsp;</span>{mediasoupClientVersion}</p>
<p className='text'><span className='label'>handler:&nbsp;&nbsp;</span>{room.mediasoupClientHandler}</p>
3 months ago
</div> */}
3 months ago
3 months ago
{/* 复制当前房间链接 */}
{/* <div className='room-link-wrapper'>
3 months ago
<div className='room-link'>
<a
className='link'
href={room.url}
target='_blank'
rel='noopener noreferrer'
onClick={(event) =>
{
// If this is a 'Open in new window/tab' don't prevent
// click default action.
if (
event.ctrlKey || event.shiftKey || event.metaKey ||
// Middle click (IE > 9 and everyone else).
(event.button && event.button === 1)
)
{
return;
}
event.preventDefault();
clipboardCopy(room.url)
.then(onRoomLinkCopy);
}}
>
invitation link
</a>
</div>
3 months ago
</div> */}
3 months ago
<Peers />
<div
className={classnames('me-container', {
'active-speaker' : amActiveSpeaker
})}
>
<Me />
</div>
<div className='chat-input-container'>
<ChatInput />
</div>
<div className='sidebar'>
<div
className={classnames('button', 'hide-videos', {
on : me.audioOnly,
disabled : me.audioOnlyInProgress
})}
3 months ago
data-tip={'将参与者的视频 显示/隐藏'}
3 months ago
onClick={() =>
{
me.audioOnly
? roomClient.disableAudioOnly()
: roomClient.enableAudioOnly();
}}
/>
<div
className={classnames('button', 'mute-audio', {
on : me.audioMuted
})}
3 months ago
data-tip={'将参与者的音频 静音/取消静音'}
3 months ago
onClick={() =>
{
me.audioMuted
? roomClient.unmuteAudio()
: roomClient.muteAudio();
}}
/>
<div
className={classnames('button', 'restart-ice', {
disabled : me.restartIceInProgress
})}
3 months ago
data-tip='重新启动 ICE'
3 months ago
onClick={() => roomClient.restartIce()}
/>
</div>
3 months ago
{/* 当前房间状态信息 */}
{/* <Stats /> */}
3 months ago
<If condition={window.NETWORK_THROTTLE_SECRET}>
<NetworkThrottle
secret={window.NETWORK_THROTTLE_SECRET}
/>
</If>
<ReactTooltip
3 months ago
place='right'
3 months ago
effect='solid'
delayShow={100}
delayHide={100}
delayUpdate={50}
/>
</div>
</Appear>
);
}
componentDidMount()
{
const { roomClient } = this.props;
roomClient.join();
}
}
Room.propTypes =
{
roomClient : PropTypes.any.isRequired,
room : appPropTypes.Room.isRequired,
me : appPropTypes.Me.isRequired,
amActiveSpeaker : PropTypes.bool.isRequired,
onRoomLinkCopy : PropTypes.func.isRequired
};
const mapStateToProps = (state) =>
{
return {
room : state.room,
me : state.me,
amActiveSpeaker : state.me.id === state.room.activeSpeakerId
};
};
const mapDispatchToProps = (dispatch) =>
{
return {
onRoomLinkCopy : () =>
{
dispatch(requestActions.notify(
{
3 months ago
text : '房间链接已复制到剪贴板'
3 months ago
}));
}
};
};
const RoomContainer = withRoomContext(connect(
mapStateToProps,
mapDispatchToProps
)(Room));
export default RoomContainer;