open socket when main component mounts

This commit is contained in:
Absurdon 2018-11-18 22:13:47 +01:00
parent 7a8518caf6
commit 5d69f56d7a
2 changed files with 3 additions and 2 deletions

View File

@ -2,7 +2,7 @@ const React = require("react");
const ReactDOM = require("react-dom");
const App = require("javascripts/components/main");
const io = require("socket.io-client");
const socketUrl = window.location.protocol + "//" + window.location.hostname + ":"+ window.location.port;
const socketUrl = window.location.origin;
const socket = io(socketUrl);
module.exports = function (mount) {

View File

@ -44,7 +44,8 @@ const App = React.createClass({
this.setState({ status: "banned" });
}
});
this.setState({ socket: socket });
this.setState({ socket: socket });
socket.open();
},
render() {