Skip to content
Permalink
Browse files

Starting on the programming behind the console.

  • Loading branch information...
roncli committed Jul 7, 2015
1 parent aea9dde commit d9dce864ebdd4a125c4a12ce21d1e5e2bb80c441
Showing with 369 additions and 300 deletions.
  1. +5 −1 index.js
  2. +2 −2 package.json
  3. +1 −1 public/index.htm
  4. +0 −252 public/js/angular-1.3.16.min.js
  5. +290 −0 public/js/angular-1.4.1.min.js
  6. +43 −1 public/js/ddsn.js
  7. +3 −3 public/templates/server-console.htm
  8. +24 −39 server.js
  9. +1 −1 websocket.js
@@ -11,7 +11,11 @@ RegExp.prototype.safeexec = function(string) {

if (result) {
result.forEach(function(item, index) {
result[index] = item.split("").join("");
if (item) {
result[index] = item.split("").join("");
} else {
result[index] = undefined;
}
});
}

@@ -18,9 +18,9 @@
"url": "https://github.com/roncli/descentDSNclient.git"
},
"dependencies": {
"descent3console": "0.1.4",
"descent3console": "0.1.5",
"descent3launcher": "0.1.3",
"descent3mn3tools": "0.1.1",
"descent3mn3tools": "0.1.2",
"express": "4.13.0",
"handlebars": "3.0.3",
"ws": "0.7.2"
@@ -2,7 +2,7 @@
<head>
<script src="/js/jquery-2.1.4.min.js"></script>
<script src="/js/bootstrap-3.3.5.min.js"></script>
<script src="/js/angular-1.3.16.min.js"></script>
<script src="/js/angular-1.4.1.min.js"></script>
<script src="/js/ddsn.js"></script>
<link rel="stylesheet" href="/css/bootstrap-slate-3.3.5.min.css"/>
<link rel="stylesheet" href="/css/bootstrap-override.css"/>

This file was deleted.

Large diffs are not rendered by default.

@@ -260,17 +260,41 @@ var app = angular.module("ddsn", []),

$scope.openServer = function(port) {
getServer(port, function(server) {
var serverConsole;

if (!server) {
return;
}

data.serverTab = "server";
data.currentServer = server;

scope.$evalAsync(function() {
setTimeout(function() {
serverConsole = $("#server-console");
if (serverConsole.length > 0) {
serverConsole[0].scrollTop = serverConsole[0].scrollHeight;
}
}, 0);
});
});
};

$scope.openServerMenu = function(screen) {
var serverConsole;

data.serverMenuTab = screen;

if (screen === "console") {
scope.$evalAsync(function() {
setTimeout(function() {
serverConsole = $("#server-console");
if (serverConsole.length > 0) {
serverConsole[0].scrollTop = serverConsole[0].scrollHeight;
}
}, 0);
});
}
};

$scope.openAddServer = function(screen) {
@@ -438,6 +462,7 @@ var app = angular.module("ddsn", []),

data.currentServer = server;
data.serverTab = "server";
data.serverMenuTab = "scoreboard";
};

$scope.updateSettingsDescent3Path = function() {
@@ -494,7 +519,7 @@ var app = angular.module("ddsn", []),
if (!server) {
return;
}
console.log(message.port);

if (data.currentServer.settings.server.port === message.port) {
data.currentServer = null;
if (data.serverTab === "server") {
@@ -523,13 +548,30 @@ console.log(message.port);
break;
case "server.raw":
getServer(message.port, function(server) {
var serverConsole,
scroll;

if (!server) {
return;
}

serverConsole = $("#server-console");

server.console.push(message.data);

scroll = serverConsole.length > 0 && serverConsole[0].scrollTop + serverConsole.innerHeight() === serverConsole[0].scrollHeight;

scope.$apply();

scope.$evalAsync(
function() {
if (scroll) {
setTimeout(function() {
serverConsole[0].scrollTop = serverConsole[0].scrollHeight;
}, 0);
}
}
);
});
break;
case "settings":
@@ -1,5 +1,5 @@
<div class="panel panel-default" style="font-family: Consolas, Lucida Console, monospace;">
<div class="panel-body" style="max-height: 500px; overflow-y: scroll;">
<div ng-repeat="line in data.currentServer.console track by $index">{{line}}</div>
</div>
<div id="server-console" class="panel-body" style="max-height: 500px; overflow-y: scroll;">
<div ng-repeat="line in data.currentServer.console | limitTo : -100 track by $index" style="white-space: pre;">{{line}}</div>
</div>
</div>
@@ -65,11 +65,24 @@ Server.prototype.connect = function() {
Server.prototype.init = function() {
"use strict";

var server = this;
var server = this,

closeServer = function(reason, err) {
server.wss.broadcast({
message: "server.close",
reason: reason,
err: err,
port: server.settings.server.port
});

this.console.removeAllListeners("error");
server.console.removeAllListeners("close");
server.console.close();
server.emit("close");
};

this.wss.broadcast({
server.console.removeAllListeners("error");

server.wss.broadcast({
message: "server.connected",
port: server.settings.server.port
});
@@ -85,52 +98,24 @@ Server.prototype.init = function() {
});

this.console.on("close", function() {
server.wss.broadcast({
message: "server.close",
reason: "close",
port: server.settings.server.port
});

server.console.removeAllListeners("close");
server.console.close();
server.emit("close");
closeServer("close");
});

this.console.on("end", function() {
server.wss.broadcast({
message: "server.close",
reason: "end",
port: server.settings.server.port
});

server.console.removeAllListeners("end");
server.console.close();
server.emit("close");
closeServer("end");
});

this.console.on("timeout", function() {
server.wss.broadcast({
message: "server.close",
reason: "timeout",
port: server.settings.server.port
});

server.console.removeAllListeners("timeout");
server.console.close();
server.emit("close");
closeServer("timeout");
});

this.console.on("error", function(err) {
server.wss.broadcast({
message: "server.close",
reason: "error",
err: err,
port: server.settings.server.port
});
closeServer("error", err);
});

server.console.removeAllListeners("error");
server.console.close();
server.emit("close");
this.console.once("loggedin", function() {
server.console.netgameInfo();
server.console.players();
});
};

@@ -447,7 +447,7 @@ module.exports = function() {
});

// Log any errors and restart the worker.
d.on("error", function(err) {
d.on("error2", function(err) {
console.log("An error occurred:", err);

if (wss) {

0 comments on commit d9dce86

Please sign in to comment.
You can’t perform that action at this time.