Working error handler

This commit is contained in:
AlexKvazos
2015-04-28 11:39:31 -05:00
parent 793fe3e162
commit 7e62e5dd79
5 changed files with 21 additions and 2 deletions
+4
View File
@@ -6,6 +6,10 @@ module.exports = function($scope, socket) {
$scope.chat = '';
if (window.location.hostname === 'chat.alexkvazos.com') {
socket.emit('chat', { message: 'Connected via web chat client / chat.alexkvazos.me.' });
}
$scope.send = function() {
if ($scope.chat.trim().length > 0) {
+4
View File
@@ -27,4 +27,8 @@ module.exports = function($scope, socket) {
});
});
$scope.disconnect = function() {
socket.emit('bot:disconnect', true);
};
};
+3 -2
View File
@@ -14,8 +14,9 @@ module.exports = function(socket) {
$('#buffer').scrollTop($('#buffer').prop('scrollHeight'));
});
socket.on('buffer:error', function(string) {
$('#buffer').append('<span style="color:#D62D18;">[i] ' + string + '</span><br>')
socket.on('buffer:error', function(error) {
if (typeof error === 'object') { error = JSON.stringify(error); }
$('#buffer').append('<span style="color:#D62D18;">[i] ' + error + '</span><br>')
$('#buffer').scrollTop($('#buffer').prop('scrollHeight'));
});
@@ -1,9 +1,18 @@
module.exports = function(socket) {
socket.on('disconnect', function() {
if (socket.mcbot) {
socket.mcbot.end();
}
});
socket.on('bot:disconnect', function() {
if (socket.mcbot) {
socket.mcbot.end();
}
});
};
+1
View File
@@ -2,6 +2,7 @@
<a class="navbar-brand" href="/">Minecraft Chat</a>
<ul class="nav navbar-nav">
<li><a style="cursor:pointer" data-toggle="modal" data-target="#connectModal">Connect</a></li>
<li><a style="cursor:pointer" ng-click="disconnect()">Disconnect</a></li>
</ul>
<ul class="nav navbar-nav pull-right">
<li ng-hide="connected"><a style="color:#9E0F06">Not Connected</a></li>