mirror of
https://github.com/Threnklyn/MinecraftChat.git
synced 2026-05-18 20:33:28 +02:00
Working error handler
This commit is contained in:
@@ -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) {
|
||||
|
||||
|
||||
@@ -27,4 +27,8 @@ module.exports = function($scope, socket) {
|
||||
});
|
||||
});
|
||||
|
||||
$scope.disconnect = function() {
|
||||
socket.emit('bot:disconnect', true);
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
};
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user