mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-11 10:43:20 +00:00
Fix duplicate IDs in VChat and add more logging
This commit is contained in:
@@ -1,5 +1,27 @@
|
||||
//The 'V' is for 'VORE' but you can pretend it's for Vue.js if you really want.
|
||||
|
||||
(function(){
|
||||
var oldLog = console.log;
|
||||
console.log = function (message) {
|
||||
send_debug(message);
|
||||
oldLog.apply(console, arguments);
|
||||
};
|
||||
var oldError = console.error;
|
||||
console.error = function (message) {
|
||||
send_debug(message);
|
||||
oldError.apply(console, arguments);
|
||||
}
|
||||
window.onerror = function (message, url, line, col, error) {
|
||||
var stacktrace = "";
|
||||
if(error && error.stack) {
|
||||
stacktrace = error.stack;
|
||||
}
|
||||
send_debug(message+" ("+url+"@"+line+":"+col+") "+error+"|UA: "+navigator.userAgent+"|Stack: "+stacktrace);
|
||||
return true;
|
||||
}
|
||||
})();
|
||||
|
||||
|
||||
//Options for vchat
|
||||
var vchat_opts = {
|
||||
crush_messages: 3, //How many messages back should we try to combine if crushing is on
|
||||
@@ -57,7 +79,10 @@ var vchat_state = {
|
||||
lastPingReply: 0,
|
||||
missedPings: 0,
|
||||
latency: 0,
|
||||
reconnecting: false
|
||||
reconnecting: false,
|
||||
|
||||
//Last ID
|
||||
lastId: 0
|
||||
}
|
||||
|
||||
function start_vchat() {
|
||||
@@ -76,6 +101,11 @@ function start_vchat() {
|
||||
//Commence the pingening
|
||||
send_ping();
|
||||
setInterval(send_ping, vchat_opts.pingThisOften);
|
||||
|
||||
//For fun
|
||||
send_debug("VChat Loaded!");
|
||||
//throw new Error("VChat Loaded!");
|
||||
|
||||
}
|
||||
|
||||
//Loads vue for chat usage
|
||||
@@ -213,7 +243,7 @@ function start_vue() {
|
||||
var stringymessages = JSON.stringify(varthis.messages);
|
||||
var unstringy = JSON.parse(stringymessages);
|
||||
unstringy.forEach( function(message) {
|
||||
message.id = (varthis.messages.length + 1);
|
||||
message.id = ++vchat_state.lastId;
|
||||
varthis.messages.push(message);
|
||||
});
|
||||
varthis.internal_message("Now have " + varthis.messages.length + " messages in array.");
|
||||
@@ -426,7 +456,7 @@ function start_vue() {
|
||||
}
|
||||
|
||||
//Append to vue's messages
|
||||
newmessage.id = (this.messages.length + 1);
|
||||
newmessage.id = ++vchat_state.lastId;
|
||||
this.messages.push(newmessage);
|
||||
},
|
||||
//Push an internally generated message into our array
|
||||
@@ -436,7 +466,7 @@ function start_vue() {
|
||||
category: "vc_system",
|
||||
content: "<span class='notice'>[VChat Internal] " + message + "</span>"
|
||||
};
|
||||
newmessage.id = (this.messages.length + 1);
|
||||
newmessage.id = ++vchat_state.lastId;
|
||||
this.messages.push(newmessage);
|
||||
},
|
||||
on_mouseup: function(event) {
|
||||
@@ -578,6 +608,11 @@ function focusMapWindow() {
|
||||
window.location = 'byond://winset?mapwindow.map.focus=true';
|
||||
}
|
||||
|
||||
//Debug event
|
||||
function send_debug(message) {
|
||||
push_Topic("debug¶m[message]="+encodeURIComponent(message));
|
||||
}
|
||||
|
||||
//A side-channel to send events over that aren't just chat messages, if necessary.
|
||||
function get_event(event) {
|
||||
if(!vchat_state.ready) {
|
||||
|
||||
11961
code/modules/vchat/js/vue.min.js
vendored
11961
code/modules/vchat/js/vue.min.js
vendored
File diff suppressed because one or more lines are too long
6
code/modules/vchat/js/vue.min.js.realmin
Normal file
6
code/modules/vchat/js/vue.min.js.realmin
Normal file
File diff suppressed because one or more lines are too long
@@ -201,10 +201,16 @@ GLOBAL_DATUM_INIT(iconCache, /savefile, new("data/iconCache.sav")) //Cache of ic
|
||||
data = bancheck(arglist(params))
|
||||
if("unloading")
|
||||
loaded = FALSE
|
||||
if("debug")
|
||||
data = debugmsg(arglist(params))
|
||||
|
||||
if(data)
|
||||
send_event(event = data)
|
||||
|
||||
//Print a message that was an error from a client
|
||||
/datum/chatOutput/proc/debugmsg(var/message = "No String Provided")
|
||||
log_debug("VChat: [owner] got: [message]")
|
||||
|
||||
//Check relevant client info reported from JS
|
||||
/datum/chatOutput/proc/bancheck(var/clientdata)
|
||||
var/list/info = json_decode(clientdata)
|
||||
|
||||
Reference in New Issue
Block a user