diff --git a/lib/actions/SupportActions.js b/lib/actions/SupportActions.js new file mode 100644 index 0000000..24dafa8 --- /dev/null +++ b/lib/actions/SupportActions.js @@ -0,0 +1,9 @@ +import alt from '../alt' + +export default alt.createActions(class SupportActions { + constructor() { + this.generateActions( + 'noSupport' + ) + } +}) diff --git a/lib/client.js b/lib/client.js index 1980c27..a36db16 100644 --- a/lib/client.js +++ b/lib/client.js @@ -2,6 +2,8 @@ import React from 'react' import ReactRouter from 'react-router' import routes from './routes' import alt from './alt' +import webrtcSupport from 'webrtcsupport' +import SupportActions from './actions/SupportActions' let bootstrap = document.documentElement.getAttribute('data-bootstrap') alt.bootstrap(bootstrap) @@ -10,4 +12,6 @@ window.FilePizza = () => { ReactRouter.run(routes, ReactRouter.HistoryLocation, function (Handler) { React.render(, document) }) + + if (!webrtcSupport.support) SupportActions.noSupport() } diff --git a/lib/components/App.js b/lib/components/App.js index 20f6ec5..4e4aaea 100644 --- a/lib/components/App.js +++ b/lib/components/App.js @@ -1,9 +1,27 @@ +import ErrorPage from './ErrorPage' import FrozenHead from 'react-frozenhead' import React from 'react' +import SupportStore from '../stores/SupportStore' import { RouteHandler } from 'react-router' export default class App extends React.Component { + constructor() { + this.state = SupportStore.getState() + + this._onChange = () => { + this.setState(SupportStore.getState()) + } + } + + componentDidMount() { + SupportStore.listen(this._onChange) + } + + componentDidUnmount() { + SupportStore.unlisten(this._onChange) + } + render() { return @@ -23,7 +41,9 @@ export default class App extends React.Component { - + {this.state.isSupported + ? + : } diff --git a/lib/stores/ErrorStore.js b/lib/stores/ErrorStore.js index f10a684..63565db 100644 --- a/lib/stores/ErrorStore.js +++ b/lib/stores/ErrorStore.js @@ -1,11 +1,20 @@ +import SupportActions from '../actions/SupportActions' import alt from '../alt' export default alt.createStore(class ErrorStore { constructor() { + this.bindActions(SupportActions) + this.status = 404 this.message = 'Not Found' this.stack = null } + onNoSupport() { + this.status = 400 + this.message = 'No WebRTC Support' + this.stack = null + } + }, 'ErrorStore') diff --git a/lib/stores/SupportStore.js b/lib/stores/SupportStore.js new file mode 100644 index 0000000..e1b531b --- /dev/null +++ b/lib/stores/SupportStore.js @@ -0,0 +1,15 @@ +import SupportActions from '../actions/SupportActions' +import alt from '../alt' + +export default alt.createStore(class SupportStore { + + constructor() { + this.bindActions(SupportActions) + this.isSupported = true + } + + onNoSupport() { + this.isSupported = false + } + +}, 'SupportStore') diff --git a/package.json b/package.json index 6ba2c8d..8e1dead 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,8 @@ "browserify-middleware": "^5.0.2", "classnames": "^1.2.0", "express": "^4.12.0", + "filepizza-peer": "./node_modules/filepizza-peer", + "filepizza-socket": "./node_modules/filepizza-socket", "morgan": "^1.5.2", "nib": "^1.1.0", "peer": "^0.2.8", @@ -33,8 +35,7 @@ "react-router": "^0.13.1", "socket.io": "^1.3.5", "stylus": "^0.50.0", - "filepizza-socket": "./node_modules/filepizza-socket", - "filepizza-peer": "./node_modules/filepizza-peer" + "webrtcsupport": "^2.1.2" }, "engines": { "node": "0.10.x"