-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
481 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { createStore, applyMiddleware, Middleware } from 'redux'; | ||
import { createBrowserHistory, History } from 'history'; | ||
import { routerMiddleware } from 'connected-react-router'; | ||
import { composeWithDevTools } from 'redux-devtools-extension'; | ||
import createRootReducer from './store/reducers'; | ||
|
||
export const history = createBrowserHistory(); | ||
|
||
const configureStore = (initialState = {}, historyInstance: History) => { | ||
const middlewares = [ | ||
routerMiddleware(historyInstance), | ||
]; | ||
|
||
const enhancers = (middlewareArray: Middleware[]) => composeWithDevTools( | ||
applyMiddleware(...middlewareArray), | ||
); | ||
|
||
const store = createStore( | ||
createRootReducer(historyInstance), | ||
initialState, | ||
enhancers(middlewares), | ||
); | ||
|
||
return store; | ||
}; | ||
|
||
export default configureStore; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,23 @@ | ||
import { connect } from 'react-redux'; | ||
import { Dispatch } from 'redux'; | ||
import ConnectContainer from './ConnectContainer'; | ||
import { webrtcActions } from '../../store/actions'; | ||
|
||
export default ConnectContainer; | ||
const mapStateToProps = (state: any) => ({ | ||
clientType: state.webrtc.clientType, | ||
}); | ||
const mapDispatchToProps = (dispatch: Dispatch) => ({ | ||
onSetLocalDescription: ( | ||
description: RTCSessionDescriptionInit, | ||
) => dispatch(webrtcActions.saveLocalDescription(description)), | ||
onGetRemoteDescription: ( | ||
description: RTCSessionDescriptionInit, | ||
) => dispatch(webrtcActions.saveRemoteDescription(description)), | ||
onGetAnswerDescription: ( | ||
description: RTCSessionDescriptionInit, | ||
) => dispatch(webrtcActions.saveAnswerDescription(description)), | ||
onSetClientType: ( | ||
clientType: string, | ||
) => dispatch(webrtcActions.setClientType(clientType)), | ||
}); | ||
export default connect(mapStateToProps, mapDispatchToProps)(ConnectContainer); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,20 @@ | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
import { Provider } from 'react-redux'; | ||
import App from './app'; | ||
import './index.less'; | ||
import rpc from './utils/rpc'; | ||
import configureStore, { history } from './configureStore'; | ||
|
||
console.log('rpc :>> ', rpc); | ||
|
||
const store = configureStore({}, history); | ||
|
||
ReactDOM.render( | ||
<React.StrictMode> | ||
<App /> | ||
<Provider store={store}> | ||
<App /> | ||
</Provider> | ||
</React.StrictMode>, | ||
document.getElementById('root'), | ||
); |
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// import { all, takeEvery } from 'redux-saga/effects'; | ||
|
||
// export default function* rootSaga() { | ||
// yield all([ | ||
|
||
// ]); | ||
// } |
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { Action } from 'redux'; | ||
import * as webrtcActions from './webrtc'; | ||
|
||
export { | ||
webrtcActions, | ||
}; | ||
|
||
export interface ActionWithPayload<T> extends Action { | ||
payload: T | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { createAction } from 'redux-actions'; | ||
import { webrtcTypes } from '../types'; | ||
|
||
export const saveLocalDescription = createAction(webrtcTypes.SAVE_LOCAL_DESCRIPTION); | ||
export const saveRemoteDescription = createAction(webrtcTypes.SAVE_REMOTE_DESCRIPTION); | ||
export const saveAnswerDescription = createAction(webrtcTypes.SAVE_ANSWER_DESCRIPTION); | ||
export const setClientType = createAction(webrtcTypes.SET_CLIENT_TYPE); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { combineReducers } from 'redux'; | ||
import { History } from 'history'; | ||
import { connectRouter } from 'connected-react-router'; | ||
import webrtc from './webrtc'; | ||
|
||
const createRootReducer = (history: History) => combineReducers({ | ||
router: connectRouter(history), | ||
webrtc, | ||
}); | ||
|
||
export default createRootReducer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { ActionWithPayload } from '../actions'; | ||
import { webrtcTypes } from '../types'; | ||
|
||
const initialState = { | ||
clientType: '', | ||
localDescription: {}, | ||
remoteDescription: {}, | ||
answerDescription: {}, | ||
}; | ||
const webrtc = (state = initialState, action: ActionWithPayload<any>) => { | ||
switch (action.type) { | ||
case webrtcTypes.SAVE_LOCAL_DESCRIPTION: | ||
return { | ||
...state, | ||
localDescription: action.payload, | ||
}; | ||
case webrtcTypes.SAVE_REMOTE_DESCRIPTION: | ||
return { | ||
...state, | ||
remoteDescription: action.payload, | ||
}; | ||
case webrtcTypes.SAVE_ANSWER_DESCRIPTION: | ||
return { | ||
...state, | ||
answerDescription: action.payload, | ||
}; | ||
case webrtcTypes.SET_CLIENT_TYPE: | ||
return { | ||
...state, | ||
clientType: action.payload, | ||
}; | ||
|
||
default: | ||
return state; | ||
} | ||
}; | ||
export default webrtc; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import * as webrtcTypes from './webrtc'; | ||
|
||
export { | ||
webrtcTypes, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export const SAVE_LOCAL_DESCRIPTION = 'store/webrtc/SAVE_LOCAL_DESCRIPTION'; | ||
export const SAVE_REMOTE_DESCRIPTION = 'store/webrtc/SAVE_REMOTE_DESCRIPTION'; | ||
export const SAVE_ANSWER_DESCRIPTION = 'store/webrtc/SAVE_ANSWER_DESCRIPTION'; | ||
export const SET_CLIENT_TYPE = 'store/webrtc/SET_CLIENT_TYPE'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.