diff --git a/client/.babelrc b/client/.babelrc new file mode 100644 index 0000000..7895cad --- /dev/null +++ b/client/.babelrc @@ -0,0 +1,3 @@ +{ + "presets": ["@vue/cli-plugin-babel/preset"] +} diff --git a/client/package.json b/client/package.json index 8adbec9..4402ce5 100644 --- a/client/package.json +++ b/client/package.json @@ -38,6 +38,7 @@ "devDependencies": { "@types/animejs": "^3.1.0", "@types/vue": "^2.0.0", + "@vue/cli-plugin-babel": "^4.1.0", "@vue/cli-plugin-eslint": "^4.1.0", "@vue/cli-plugin-typescript": "^4.1.0", "@vue/cli-plugin-vuex": "^4.1.0", diff --git a/client/src/app.vue b/client/src/app.vue index 479a887..5912ef6 100644 --- a/client/src/app.vue +++ b/client/src/app.vue @@ -1,31 +1,36 @@ @@ -113,6 +118,7 @@ import Emotes from '~/components/emotes.vue' import About from '~/components/about.vue' import Header from '~/components/header.vue' + import Unsupported from '~/components/unsupported.vue' @Component({ name: 'neko', @@ -126,6 +132,7 @@ 'neko-emotes': Emotes, 'neko-about': About, 'neko-header': Header, + 'neko-unsupported': Unsupported, }, }) export default class extends Vue { diff --git a/client/src/components/unsupported.vue b/client/src/components/unsupported.vue new file mode 100644 index 0000000..8469957 --- /dev/null +++ b/client/src/components/unsupported.vue @@ -0,0 +1,75 @@ + + + + + diff --git a/client/src/neko/base.ts b/client/src/neko/base.ts index 33f2010..7998098 100644 --- a/client/src/neko/base.ts +++ b/client/src/neko/base.ts @@ -1,7 +1,5 @@ import EventEmitter from 'eventemitter3' - import { OPCODE } from './data' - import { EVENT, WebSocketEvents } from './events' import { @@ -29,6 +27,10 @@ export abstract class BaseClient extends EventEmitter { protected _username?: string protected _state: RTCIceConnectionState = 'disconnected' + get supported() { + return typeof RTCPeerConnection !== 'undefined' && typeof RTCPeerConnection.prototype.addTransceiver !== 'undefined' + } + get socketOpen() { return typeof this._ws !== 'undefined' && this._ws.readyState === WebSocket.OPEN } @@ -47,6 +49,11 @@ export abstract class BaseClient extends EventEmitter { return } + if (!this.supported) { + this.onDisconnected(new Error('browser does not support webrtc (RTCPeerConnection missing)')) + return + } + if (username === '') { throw new Error('Must add a username') // TODO: Better handleing }