Skip to content

Commit 1b82102

Browse files
author
Ari
committed
WIP
1 parent 6059ca8 commit 1b82102

File tree

7 files changed

+47
-79
lines changed

7 files changed

+47
-79
lines changed

Diff for: config/production.config.js

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
TURN_SERVER=https://runfullstack.co:8080/

Diff for: src/components/Rooms/VideoView.js

-40
This file was deleted.

Diff for: src/redux/modules/webrtc.js

+13
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export const types = createConstants('webrtc')(
99

1010
'LOCAL_MEDIA_START',
1111
'LOCAL_MEDIA_ERROR',
12+
'LOCAL_MEDIA_STOP',
1213

1314
'PEER_STREAM_ADDED',
1415
'PEER_STREAM_REMOVED',
@@ -39,6 +40,11 @@ export const reducer = createReducer({
3940
localStreamError: payload
4041
}),
4142

43+
[types.LOCAL_MEDIA_STOP]: (state, {payload}) => ({
44+
...state,
45+
localStream: null
46+
}),
47+
4248
[types.PEER_STREAM_ADDED]: (state, {payload}) => {
4349
const peers = rtc.webrtc.getPeers();
4450
return {...state, peers}
@@ -91,6 +97,7 @@ export const actions = {
9197
return {type: types.JOIN_ROOM, payload: room}
9298
},
9399
leaveRoom: (room) => {
100+
rtc.leaveRoom(room);
94101
return {type: types.LEAVE_ROOM, payload: room}
95102
},
96103
startLocalMedia: (config = {}) => (dispatch) => {
@@ -103,6 +110,12 @@ export const actions = {
103110
dispatch({type: types.LOCAL_MEDIA_START, payload: stream})
104111
}
105112
});
113+
},
114+
stopLocalMedia: () => {
115+
rtc.stopLocalVideo();
116+
return {
117+
type: types.LOCAL_MEDIA_STOP
118+
}
106119
}
107120
}
108121

Diff for: src/views/main/indexPage/Page.js

+12-23
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,6 @@ export class Index extends React.Component {
1313
const {actions, params} = this.props;
1414
}
1515

16-
goToAbout(evt) {
17-
const {router} = this.context;
18-
const {actions} = this.props;
19-
actions.routing.navigateTo('about');
20-
return false;
21-
}
22-
2316
newChat(evt) {
2417
evt.preventDefault();
2518
const {actions} = this.props;
@@ -39,22 +32,18 @@ export class Index extends React.Component {
3932

4033
return (
4134
<div className={styles.container}>
42-
<div className={[styles.grid]}>
43-
<div className={[styles.row, styles.smallRow]}>
44-
<div className={styles.actions}>
45-
<form className={formStyles.form}
46-
onSubmit={this.newChat.bind(this)}>
47-
<input name="roomName"
48-
ref="roomName"
49-
className={[formStyles.input]}
50-
placeholder="Get a room (or leave blank for randomly generated one)" />
51-
<input type="submit"
52-
className={[formStyles.btn, styles.actions].join(' ')}
53-
onClick={this.newChat.bind(this)}
54-
value="New chat" />
55-
</form>
56-
</div>
57-
</div>
35+
<div className={[styles.row, styles.smallRow]}>
36+
<form className={formStyles.form}
37+
onSubmit={this.newChat.bind(this)}>
38+
<input name="roomName"
39+
ref="roomName"
40+
className={[formStyles.input]}
41+
placeholder="Get a room (or leave blank for randomly generated one)" />
42+
<input type="submit"
43+
className={[formStyles.btn, styles.actions].join(' ')}
44+
onClick={this.newChat.bind(this)}
45+
value="New chat" />
46+
</form>
5847
</div>
5948
</div>
6049
)

Diff for: src/views/main/indexPage/styles.module.css

+1-14
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,11 @@
11
@import url('../../../styles/base.css');
22
@import url('../../../styles/colors.css');
33

4-
.room {
5-
}
6-
7-
.actions {
8-
text-align: center;
9-
}
10-
11-
.grid {
12-
}
13-
144
.row {
155
display: flex;
166
flex-direction: row;
177
flex-wrap: wrap;
18-
}
19-
20-
.room {
21-
flex: 1;
8+
text-align: center;
229
}
2310

2411
@media all and ( min-width: 480px ) {

Diff for: src/views/main/video/Page.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,13 @@ export class VideoIndex extends React.Component {
4747
leaveRoom(roomName) {
4848
const {actions} = this.props;
4949
actions.webrtc.leaveRoom(roomName);
50-
actions.routing.navigateTo('/')
50+
actions.routing.navigateTo('/');
51+
}
52+
53+
componentWillUnmount() {
54+
const {actions} = this.props;
55+
actions.webrtc.stopLocalMedia();
56+
this.leaveRoom(this.props.roomName);
5157
}
5258

5359
render() {

Diff for: webpack.config.js

+13-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ const getConfig = require('hjs-webpack');
1212
const isDev = NODE_ENV === 'development';
1313
const isTest = NODE_ENV === 'test';
1414

15+
// devServer config
16+
const devHost = process.env.HOST || 'localhost';
17+
const devPort = process.env.PORT || 3000;
18+
1519
const root = resolve(__dirname);
1620
const src = join(root, 'src');
1721
const modules = join(root, 'node_modules');
@@ -27,7 +31,7 @@ var config = getConfig({
2731
return {
2832
'index.html': context.defaultTemplate({
2933
title: 'callerId',
30-
publicPath: isDev ? '//localhost:3000/' : '',
34+
publicPath: isDev ? `//${devHost}:${devPort}/` : '',
3135
meta: {}
3236
})
3337
};
@@ -54,6 +58,8 @@ const defines =
5458
__DEBUG__: isDev
5559
});
5660

61+
console.log('defines', defines);
62+
5763
config.plugins = [
5864
new webpack.DefinePlugin(defines)
5965
].concat(config.plugins);
@@ -115,6 +121,12 @@ config.externals = {
115121
'ws': true
116122
}
117123

124+
// Dev
125+
if (isDev) {
126+
config.devServer.port = devPort;
127+
config.devServer.hostname = devHost;
128+
}
129+
118130
// console.log(require('prettyjson').render(config));
119131
// Testing
120132
if (isTest) {

0 commit comments

Comments
 (0)