MCSM:WebConsole: полученые данных с websocket
This commit is contained in:
@@ -65,21 +65,33 @@ var Tabs = React.createClass({
|
||||
});
|
||||
|
||||
var WebConsole = React.createClass({
|
||||
render: function(){return(
|
||||
ce('div', {id: 'webconsole'},
|
||||
ce('p', null, '[19:50:18 WARN]: **** SERVER IS RUNNING IN OFFLINE/INSECURE MODE!'),
|
||||
ce('p', null, '[19:50:18 WARN]: The server will make no attempt to authenticate usernames. Beware.'),
|
||||
ce('p', null, '[19:50:18 WARN]: While this makes the game possible to play without internet access, it also opens up the ability for hackers to connect with any username they choose.'),
|
||||
ce('p', null, '[19:50:18 WARN]: To change this, set "online-mode" to "true" in the server.properties file.'),
|
||||
ce('p', null, '[19:50:18 INFO]: **** Beginning UUID conversion, this may take A LONG time ****'),
|
||||
ce('p', null, '[19:50:18 INFO]: Preparing level "voidworld"'),
|
||||
ce('p', null, '[19:50:18 INFO]: -------- World Settings For [voidworld] --------'),
|
||||
ce('p', null, '[19:50:18 INFO]: Arrow Despawn Rate: 1200'),
|
||||
ce('p', null, '[19:50:18 INFO]: Item Merge Radius: 2.5'),
|
||||
ce('p', null, '[19:50:18 INFO]: Item Despawn Rate: 6000'),
|
||||
ce('p', null, '[19:50:18 INFO]: Allow Zombie Pigmen to spawn from portal blocks: true')
|
||||
ws: null,
|
||||
/*--------------------*/
|
||||
getInitialState: function(){return{
|
||||
lines: []
|
||||
}},
|
||||
render: function(){
|
||||
return(
|
||||
ce('div', {id: 'webconsole', ref: 'webconsole'}, this.state.lines.map(function(line){ return ce('p', null, line); }))
|
||||
)
|
||||
)}
|
||||
},
|
||||
componentDidMount: function(){
|
||||
var _this = this;
|
||||
|
||||
this.ws = new WebSocket("ws://127.0.0.1:8770"); //FIXME указывать ip:port из настроек
|
||||
this.ws.onopen = function(){ console.debug('WS: open...'); };
|
||||
this.ws.onclose = function(){ console.debug('WS: close...'); };
|
||||
this.ws.onmessage = function(event){
|
||||
console.debug('WS: message: '+event.data);
|
||||
_this.setState({ lines: _this.state.lines.concat([event.data]) });
|
||||
};
|
||||
},
|
||||
componentDidUpdate: function() {
|
||||
// this.refs.webconsole.scrollTop = this.refs.webconsole.scrollHeight;
|
||||
},
|
||||
componentWillUnmount: function(){
|
||||
this.ws.close();
|
||||
}
|
||||
});
|
||||
|
||||
var ServerInfo = React.createClass({
|
||||
|
||||
Reference in New Issue
Block a user