@@ -4,10 +4,21 @@ const http = require('http');
44var server = http . createServer ( ) ;
55var io = require ( "socket.io" ) ( server ) ;
66
7+ function exec ( cmd ) {
8+ const exec = require ( 'child_process' ) . exec ;
9+ return new Promise ( ( resolve , reject ) => {
10+ exec ( cmd , ( error , stdout , stderr ) => {
11+ if ( error ) {
12+ console . warn ( error ) ;
13+ }
14+ resolve ( stdout ? stdout : stderr ) ;
15+ } ) ;
16+ } ) ;
17+ }
18+
719var config = JSON . parse ( fs . readFileSync ( __dirname + '/config.json' ) )
820
921require ( "./server/express.js" ) ( config )
10- opn ( `http://${ config [ "host" ] } :${ config [ "express-port" ] } ` )
1122
1223//WebSocket
1324 var world = { } ;
@@ -52,13 +63,16 @@ opn(`http://${config["host"]}:${config["express-port"]}`)
5263
5364//Terminal client
5465 var term = require ( 'terminal-kit' ) . terminal ;
66+ term . windowTitle ( "web-minecraft console" )
5567 term . clear ( )
5668 term . green ( ( fs . readFileSync ( __dirname + '/src/asciiLogo' ) ) )
5769 info ( )
5870 // // Get some user input
5971
6072 incon ( )
61-
73+ function log ( message ) {
74+ term ( `\n${ message } \n` )
75+ }
6276 function stop ( ) {
6377 term . brightGreen ( "\nServer stopped!\n" )
6478 process . exit ( )
@@ -68,6 +82,7 @@ opn(`http://${config["host"]}:${config["express-port"]}`)
6882help\t- pomoc
6983stop\t- zatrzymanie serwera
7084open\t- uruchomienie przeglądarki pod adresem serwera
85+ copen\t- uruchamianie gry w przeglądarce chrome w wersji 'app'
7186list\t- wypisuje wszystkich aktywnych użytkowników
7287clear\t- czyści consolę
7388info\t- wypisuje informacje o serwerze
@@ -91,6 +106,8 @@ info\t- wypisuje informacje o serwerze
91106 } )
92107 } else if ( command == "open" ) {
93108 opn ( `http://${ config [ "host" ] } :${ config [ "express-port" ] } ` )
109+ } else if ( command == "copen" ) {
110+ exec ( `google-chrome --app=http://${ config [ "host" ] } :${ config [ "express-port" ] } ` )
94111 } else if ( command == "info" ) {
95112 info ( )
96113 } else if ( command != "" ) {
@@ -109,7 +126,8 @@ info\t- wypisuje informacje o serwerze
109126 'open' ,
110127 'clear' ,
111128 'info' ,
112- 'list'
129+ 'list' ,
130+ 'copen'
113131 ] ,
114132 autoCompleteHint : true ,
115133 autoCompleteMenu : true ,
0 commit comments