Add basic socket.io and notification functionality

This commit is contained in:
2016-12-22 17:40:05 -07:00
parent 8a6d3c0f11
commit 14644ee21b
3 changed files with 48 additions and 14 deletions

View File

@@ -1,5 +1,6 @@
'use strict';
import React from 'react';
import io from 'socket.io-client';
export default class NotifPage extends React.Component {
constructor(props) {
@@ -10,13 +11,27 @@ export default class NotifPage extends React.Component {
}
}
componentDidMount() {
let socket = io.connect();
let room = this.props.urlid;
socket.on('connect', () => {
socket.emit('room', room);
});
socket.on('message', (data) => {
new Notification(data);
});
}
checkperm(permission) {
if (permission === 'granted') {
this.setState({haveperm: true});
}
}
render(){
render() {
let supported = ("Notification" in window);
if (supported) {