diff options
| author | RblSb <msrblsb@gmail.com> | 2020-05-21 19:06:34 +0300 |
|---|---|---|
| committer | RblSb <msrblsb@gmail.com> | 2020-05-21 19:08:53 +0300 |
| commit | 5d958025e72956e77d3dfc0aa659e9b04f394201 (patch) | |
| tree | bef65ab8d9f291b832372e3f56d632e6ee6398e3 | |
| parent | f64eab6a6170edeee6f3251bf89c8422e91df3b7 (diff) | |
Disable client debug messages
now in server --verbose run
| -rw-r--r-- | build/server.js | 36 | ||||
| -rw-r--r-- | res/client.js | 27 | ||||
| -rw-r--r-- | src/Types.hx | 1 | ||||
| -rw-r--r-- | src/client/Main.hx | 8 | ||||
| -rw-r--r-- | src/server/Main.hx | 1 |
5 files changed, 40 insertions, 33 deletions
diff --git a/build/server.js b/build/server.js index 7d2a7dd..737e47b 100644 --- a/build/server.js +++ b/build/server.js @@ -1407,7 +1407,7 @@ JsonParser_$52.__name__ = true; JsonParser_$52.__super__ = json2object_reader_BaseParser; JsonParser_$52.prototype = $extend(json2object_reader_BaseParser.prototype,{ onIncorrectType: function(pos,variable) { - this.errors.push(json2object_Error.IncorrectType(variable,"{ youtubeApiKey : String, userVideoLimit : Int, totalVideoLimit : Int, templateUrl : String, serverChatHistory : Int, ?salt : Null<String>, port : Int, permissions : { user : Array<Permission>, leader : Array<Permission>, guest : Array<Permission>, admin : Array<Permission> }, maxMessageLength : Int, maxLoginLength : Int, localAdmins : Bool, filters : Array<Filter>, emotes : Array<Emote>, channelName : String }",pos)); + this.errors.push(json2object_Error.IncorrectType(variable,"{ youtubeApiKey : String, userVideoLimit : Int, totalVideoLimit : Int, templateUrl : String, serverChatHistory : Int, ?salt : Null<String>, port : Int, permissions : { user : Array<Permission>, leader : Array<Permission>, guest : Array<Permission>, admin : Array<Permission> }, maxMessageLength : Int, maxLoginLength : Int, localAdmins : Bool, ?isVerbose : Null<Bool>, filters : Array<Filter>, emotes : Array<Emote>, channelName : String }",pos)); json2object_reader_BaseParser.prototype.onIncorrectType.call(this,pos,variable); } ,loadJsonNull: function(pos,variable) { @@ -1415,7 +1415,7 @@ JsonParser_$52.prototype = $extend(json2object_reader_BaseParser.prototype,{ } ,loadJsonObject: function(o,pos,variable) { var assigned = new haxe_ds_StringMap(); - this.objectSetupAssign(assigned,["channelName","emotes","filters","localAdmins","maxLoginLength","maxMessageLength","permissions","port","salt","serverChatHistory","templateUrl","totalVideoLimit","userVideoLimit","youtubeApiKey"],[false,false,false,false,false,false,false,false,true,false,false,false,false,false]); + this.objectSetupAssign(assigned,["channelName","emotes","filters","isVerbose","localAdmins","maxLoginLength","maxMessageLength","permissions","port","salt","serverChatHistory","templateUrl","totalVideoLimit","userVideoLimit","youtubeApiKey"],[false,false,false,true,false,false,false,false,false,true,false,false,false,false,false]); this.value = this.getAuto(); var _g = 0; while(_g < o.length) { @@ -1431,6 +1431,9 @@ JsonParser_$52.prototype = $extend(json2object_reader_BaseParser.prototype,{ case "filters": this.value.filters = this.loadObjectField(($_=new JsonParser_$57(this.errors,this.putils,1),$bind($_,$_.loadJson)),field,"filters",assigned,this.value.filters,pos); break; + case "isVerbose": + this.value.isVerbose = this.loadObjectField(($_=new JsonParser_$46(this.errors,this.putils,1),$bind($_,$_.loadJson)),field,"isVerbose",assigned,this.value.isVerbose,pos); + break; case "localAdmins": this.value.localAdmins = this.loadObjectField(($_=new JsonParser_$38(this.errors,this.putils,1),$bind($_,$_.loadJson)),field,"localAdmins",assigned,this.value.localAdmins,pos); break; @@ -1471,7 +1474,7 @@ JsonParser_$52.prototype = $extend(json2object_reader_BaseParser.prototype,{ this.objectErrors(assigned,pos); } ,getAuto: function() { - return { channelName : new JsonParser_$36([],this.putils,0).loadJson(new hxjsonast_Json(hxjsonast_JsonValue.JNull,new hxjsonast_Position("",0,1))), emotes : new JsonParser_$56([],this.putils,0).loadJson(new hxjsonast_Json(hxjsonast_JsonValue.JNull,new hxjsonast_Position("",0,1))), filters : new JsonParser_$57([],this.putils,0).loadJson(new hxjsonast_Json(hxjsonast_JsonValue.JNull,new hxjsonast_Position("",0,1))), localAdmins : new JsonParser_$38([],this.putils,0).loadJson(new hxjsonast_Json(hxjsonast_JsonValue.JNull,new hxjsonast_Position("",0,1))), maxLoginLength : new JsonParser_$42([],this.putils,0).loadJson(new hxjsonast_Json(hxjsonast_JsonValue.JNull,new hxjsonast_Position("",0,1))), maxMessageLength : new JsonParser_$42([],this.putils,0).loadJson(new hxjsonast_Json(hxjsonast_JsonValue.JNull,new hxjsonast_Position("",0,1))), permissions : new JsonParser_$58([],this.putils,0).loadJson(new hxjsonast_Json(hxjsonast_JsonValue.JNull,new hxjsonast_Position("",0,1))), port : new JsonParser_$42([],this.putils,0).loadJson(new hxjsonast_Json(hxjsonast_JsonValue.JNull,new hxjsonast_Position("",0,1))), salt : new JsonParser_$48([],this.putils,0).loadJson(new hxjsonast_Json(hxjsonast_JsonValue.JNull,new hxjsonast_Position("",0,1))), serverChatHistory : new JsonParser_$42([],this.putils,0).loadJson(new hxjsonast_Json(hxjsonast_JsonValue.JNull,new hxjsonast_Position("",0,1))), templateUrl : new JsonParser_$36([],this.putils,0).loadJson(new hxjsonast_Json(hxjsonast_JsonValue.JNull,new hxjsonast_Position("",0,1))), totalVideoLimit : new JsonParser_$42([],this.putils,0).loadJson(new hxjsonast_Json(hxjsonast_JsonValue.JNull,new hxjsonast_Position("",0,1))), userVideoLimit : new JsonParser_$42([],this.putils,0).loadJson(new hxjsonast_Json(hxjsonast_JsonValue.JNull,new hxjsonast_Position("",0,1))), youtubeApiKey : new JsonParser_$36([],this.putils,0).loadJson(new hxjsonast_Json(hxjsonast_JsonValue.JNull,new hxjsonast_Position("",0,1)))}; + return { channelName : new JsonParser_$36([],this.putils,0).loadJson(new hxjsonast_Json(hxjsonast_JsonValue.JNull,new hxjsonast_Position("",0,1))), emotes : new JsonParser_$56([],this.putils,0).loadJson(new hxjsonast_Json(hxjsonast_JsonValue.JNull,new hxjsonast_Position("",0,1))), filters : new JsonParser_$57([],this.putils,0).loadJson(new hxjsonast_Json(hxjsonast_JsonValue.JNull,new hxjsonast_Position("",0,1))), isVerbose : new JsonParser_$46([],this.putils,0).loadJson(new hxjsonast_Json(hxjsonast_JsonValue.JNull,new hxjsonast_Position("",0,1))), localAdmins : new JsonParser_$38([],this.putils,0).loadJson(new hxjsonast_Json(hxjsonast_JsonValue.JNull,new hxjsonast_Position("",0,1))), maxLoginLength : new JsonParser_$42([],this.putils,0).loadJson(new hxjsonast_Json(hxjsonast_JsonValue.JNull,new hxjsonast_Position("",0,1))), maxMessageLength : new JsonParser_$42([],this.putils,0).loadJson(new hxjsonast_Json(hxjsonast_JsonValue.JNull,new hxjsonast_Position("",0,1))), permissions : new JsonParser_$58([],this.putils,0).loadJson(new hxjsonast_Json(hxjsonast_JsonValue.JNull,new hxjsonast_Position("",0,1))), port : new JsonParser_$42([],this.putils,0).loadJson(new hxjsonast_Json(hxjsonast_JsonValue.JNull,new hxjsonast_Position("",0,1))), salt : new JsonParser_$48([],this.putils,0).loadJson(new hxjsonast_Json(hxjsonast_JsonValue.JNull,new hxjsonast_Position("",0,1))), serverChatHistory : new JsonParser_$42([],this.putils,0).loadJson(new hxjsonast_Json(hxjsonast_JsonValue.JNull,new hxjsonast_Position("",0,1))), templateUrl : new JsonParser_$36([],this.putils,0).loadJson(new hxjsonast_Json(hxjsonast_JsonValue.JNull,new hxjsonast_Position("",0,1))), totalVideoLimit : new JsonParser_$42([],this.putils,0).loadJson(new hxjsonast_Json(hxjsonast_JsonValue.JNull,new hxjsonast_Position("",0,1))), userVideoLimit : new JsonParser_$42([],this.putils,0).loadJson(new hxjsonast_Json(hxjsonast_JsonValue.JNull,new hxjsonast_Position("",0,1))), youtubeApiKey : new JsonParser_$36([],this.putils,0).loadJson(new hxjsonast_Json(hxjsonast_JsonValue.JNull,new hxjsonast_Position("",0,1)))}; } ,__class__: JsonParser_$52 }); @@ -3334,6 +3337,7 @@ var server_Main = function() { this.loadState(); this.config = this.loadUserConfig(); this.userList = this.loadUsers(); + this.config.isVerbose = this.verbose; this.config.salt = this.generateConfigSalt(); this.localIp = server_Utils.getLocalIp(); this.globalIp = this.localIp; @@ -3344,8 +3348,8 @@ var server_Main = function() { } server_Utils.getGlobalIp(function(ip) { _gthis.globalIp = ip; - haxe_Log.trace("Local: http://" + _gthis.localIp + ":" + _gthis.port,{ fileName : "src/server/Main.hx", lineNumber : 85, className : "server.Main", methodName : "new"}); - haxe_Log.trace("Global: http://" + _gthis.globalIp + ":" + _gthis.port,{ fileName : "src/server/Main.hx", lineNumber : 86, className : "server.Main", methodName : "new"}); + haxe_Log.trace("Local: http://" + _gthis.localIp + ":" + _gthis.port,{ fileName : "src/server/Main.hx", lineNumber : 86, className : "server.Main", methodName : "new"}); + haxe_Log.trace("Global: http://" + _gthis.globalIp + ":" + _gthis.port,{ fileName : "src/server/Main.hx", lineNumber : 87, className : "server.Main", methodName : "new"}); }); var dir = "" + this.rootDir + "/res"; server_HttpServer.init(dir,"" + this.rootDir + "/user/res",this.config.localAdmins); @@ -3418,7 +3422,7 @@ server_Main.prototype = { var field = _g1[_g]; ++_g; if(Reflect.field(config,field) == null) { - haxe_Log.trace("Warning: config field \"" + field + "\" is unknown",{ fileName : "src/server/Main.hx", lineNumber : 140, className : "server.Main", methodName : "getUserConfig"}); + haxe_Log.trace("Warning: config field \"" + field + "\" is unknown",{ fileName : "src/server/Main.hx", lineNumber : 141, className : "server.Main", methodName : "getUserConfig"}); } config[field] = Reflect.field(customConfig,field); } @@ -3429,14 +3433,14 @@ server_Main.prototype = { var emote = _g1[_g]; ++_g; if(emoteCopies_h[emote.name]) { - haxe_Log.trace("Warning: emote name \"" + emote.name + "\" has copy",{ fileName : "src/server/Main.hx", lineNumber : 145, className : "server.Main", methodName : "getUserConfig"}); + haxe_Log.trace("Warning: emote name \"" + emote.name + "\" has copy",{ fileName : "src/server/Main.hx", lineNumber : 146, className : "server.Main", methodName : "getUserConfig"}); } emoteCopies_h[emote.name] = true; if(!this.verbose) { continue; } if(emoteCopies_h[emote.image]) { - haxe_Log.trace("Warning: emote url of name \"" + emote.name + "\" has copy",{ fileName : "src/server/Main.hx", lineNumber : 148, className : "server.Main", methodName : "getUserConfig"}); + haxe_Log.trace("Warning: emote url of name \"" + emote.name + "\" has copy",{ fileName : "src/server/Main.hx", lineNumber : 149, className : "server.Main", methodName : "getUserConfig"}); } emoteCopies_h[emote.image] = true; } @@ -3457,7 +3461,7 @@ server_Main.prototype = { js_node_Fs.writeFileSync("" + folder + "/users.json",JSON.stringify(users,null,"\t")); } ,saveState: function() { - haxe_Log.trace("Saving state...",{ fileName : "src/server/Main.hx", lineNumber : 172, className : "server.Main", methodName : "saveState"}); + haxe_Log.trace("Saving state...",{ fileName : "src/server/Main.hx", lineNumber : 173, className : "server.Main", methodName : "saveState"}); var json = JSON.stringify({ videoList : this.videoList, isPlaylistOpen : this.isPlaylistOpen, itemPos : this.itemPos, messages : this.messages, timer : { time : this.videoTimer.getTime(), paused : this.videoTimer.isPaused()}},null,"\t"); js_node_Fs.writeFileSync(this.statePath,json); } @@ -3465,7 +3469,7 @@ server_Main.prototype = { if(!sys_FileSystem.exists(this.statePath)) { return; } - haxe_Log.trace("Loading state...",{ fileName : "src/server/Main.hx", lineNumber : 189, className : "server.Main", methodName : "loadState"}); + haxe_Log.trace("Loading state...",{ fileName : "src/server/Main.hx", lineNumber : 190, className : "server.Main", methodName : "loadState"}); var data = JSON.parse(js_node_Fs.readFileSync(this.statePath,{ encoding : "utf8"})); this.videoList.length = 0; this.messages.length = 0; @@ -3482,7 +3486,7 @@ server_Main.prototype = { this.videoTimer.pause(); } ,logError: function(type,data) { - haxe_Log.trace(type,{ fileName : "src/server/Main.hx", lineNumber : 203, className : "server.Main", methodName : "logError", customParams : [data]}); + haxe_Log.trace(type,{ fileName : "src/server/Main.hx", lineNumber : 204, className : "server.Main", methodName : "logError", customParams : [data]}); var crashesFolder = "" + this.rootDir + "/user/crashes"; if(!sys_FileSystem.exists(crashesFolder)) { sys_FileSystem.createDirectory(crashesFolder); @@ -3500,7 +3504,7 @@ server_Main.prototype = { if(_gthis.clients.length == 0) { return; } - haxe_Log.trace("Ping " + url,{ fileName : "src/server/Main.hx", lineNumber : 218, className : "server.Main", methodName : "initIntergationHandlers"}); + haxe_Log.trace("Ping " + url,{ fileName : "src/server/Main.hx", lineNumber : 219, className : "server.Main", methodName : "initIntergationHandlers"}); js_node_Http.get(url,null,function(r) { }); }; @@ -3514,14 +3518,14 @@ server_Main.prototype = { } this.userList.admins.push({ name : name, hash : hash}); this.writeUsers(this.userList); - haxe_Log.trace("Admin " + name + " added.",{ fileName : "src/server/Main.hx", lineNumber : 233, className : "server.Main", methodName : "addAdmin"}); + haxe_Log.trace("Admin " + name + " added.",{ fileName : "src/server/Main.hx", lineNumber : 234, className : "server.Main", methodName : "addAdmin"}); } ,onConnect: function(ws,req) { var _gthis = this; var ip = req.connection.remoteAddress; var id = this.freeIds.length > 0 ? this.freeIds.shift() : this.clients.length; var name = "Guest " + (id + 1); - haxe_Log.trace("" + name + " connected (" + ip + ")",{ fileName : "src/server/Main.hx", lineNumber : 240, className : "server.Main", methodName : "onConnect"}); + haxe_Log.trace("" + name + " connected (" + ip + ")",{ fileName : "src/server/Main.hx", lineNumber : 241, className : "server.Main", methodName : "onConnect"}); var client = new Client(ws,req,id,name,0); client.setGroupFlag(ClientGroup.Admin,this.config.localAdmins && req.connection.localAddress == ip); this.clients.push(client); @@ -3544,14 +3548,14 @@ server_Main.prototype = { var obj = _gthis.wsEventParser.fromJson(data); if(_gthis.wsEventParser.errors.length > 0) { var errors = "" + ("Wrong request for type \"" + obj.type + "\":") + "\n" + json2object_ErrorUtils.convertErrorArray(_gthis.wsEventParser.errors); - haxe_Log.trace(errors,{ fileName : "src/server/Main.hx", lineNumber : 272, className : "server.Main", methodName : "onConnect"}); + haxe_Log.trace(errors,{ fileName : "src/server/Main.hx", lineNumber : 273, className : "server.Main", methodName : "onConnect"}); _gthis.serverMessage(client,errors); return; } _gthis.onMessage(client,obj); }); ws.on("close",function(err) { - haxe_Log.trace("Client " + client.name + " disconnected",{ fileName : "src/server/Main.hx", lineNumber : 279, className : "server.Main", methodName : "onConnect"}); + haxe_Log.trace("Client " + client.name + " disconnected",{ fileName : "src/server/Main.hx", lineNumber : 280, className : "server.Main", methodName : "onConnect"}); server_Utils.sortedPush(_gthis.freeIds,client.id); HxOverrides.remove(_gthis.clients,client); _gthis.sendClientList(); diff --git a/res/client.js b/res/client.js index e29233e..787dcf6 100644 --- a/res/client.js +++ b/res/client.js @@ -1115,9 +1115,10 @@ client_Main.prototype = { } ,onMessage: function(e) { var data = JSON.parse(e.data); - var t = data.type; - var t1 = t.charAt(0).toLowerCase() + HxOverrides.substr(t,1,null); - haxe_Log.trace("Event: " + data.type,{ fileName : "src/client/Main.hx", lineNumber : 324, className : "client.Main", methodName : "onMessage", customParams : [data[t1]]}); + if(this.config != null && this.config.isVerbose) { + var t = data.type; + haxe_Log.trace("Event: " + data.type,{ fileName : "src/client/Main.hx", lineNumber : 325, className : "client.Main", methodName : "onMessage", customParams : [Reflect.field(data,t.charAt(0).toLowerCase() + HxOverrides.substr(t,1,null))]}); + } switch(data.type) { case "AddVideo": this.player.addVideoItem(data.addVideo.item,data.addVideo.atEnd); @@ -1151,7 +1152,7 @@ client_Main.prototype = { var synchThreshold = this.settings.synchThreshold; var newTime = data.getTime.time; var time = this.player.getTime(); - if((this.personal.group & 1 << ClientGroup.Leader._hx_index) != 0 && !this.forceSyncNextTick) { + if((this.personal.group & 2) != 0 && !this.forceSyncNextTick) { if(Math.abs(time - newTime) < synchThreshold) { return; } @@ -1198,14 +1199,14 @@ client_Main.prototype = { this.showGuestPasswordPanel(); break; case "Pause": - if((this.personal.group & 1 << ClientGroup.Leader._hx_index) != 0) { + if((this.personal.group & 2) != 0) { return; } this.player.pause(); this.player.setTime(data.pause.time); break; case "Play": - if((this.personal.group & 1 << ClientGroup.Leader._hx_index) != 0) { + if((this.personal.group & 2) != 0) { return; } this.player.setTime(data.play.time); @@ -1225,14 +1226,13 @@ client_Main.prototype = { break; case "ServerMessage": var id = data.serverMessage.textId; - var text = id == "usernameError" ? StringTools.replace(Lang.get(id),"$MAX","" + this.config.maxLoginLength) : Lang.get(id); - this.serverMessage(4,text); + this.serverMessage(4,id == "usernameError" ? StringTools.replace(Lang.get(id),"$MAX","" + this.config.maxLoginLength) : Lang.get(id)); break; case "SetLeader": ClientTools.setLeader(this.clients,data.setLeader.clientName); this.updateUserList(); - this.setLeaderButton((this.personal.group & 1 << ClientGroup.Leader._hx_index) != 0); - if((this.personal.group & 1 << ClientGroup.Leader._hx_index) != 0) { + this.setLeaderButton((this.personal.group & 2) != 0); + if((this.personal.group & 2) != 0) { this.player.setTime(this.player.getTime(),false); } break; @@ -1240,7 +1240,7 @@ client_Main.prototype = { this.player.setNextItem(data.setNextItem.pos); break; case "SetRate": - if((this.personal.group & 1 << ClientGroup.Leader._hx_index) != 0) { + if((this.personal.group & 2) != 0) { return; } this.player.setPlaybackRate(data.setRate.rate); @@ -1248,8 +1248,7 @@ client_Main.prototype = { case "SetTime": var synchThreshold = this.settings.synchThreshold; var newTime = data.setTime.time; - var time = this.player.getTime(); - if(Math.abs(time - newTime) < synchThreshold) { + if(Math.abs(this.player.getTime() - newTime) < synchThreshold) { return; } this.player.setTime(newTime); @@ -1278,7 +1277,7 @@ client_Main.prototype = { case "VideoLoaded": this.player.setTime(0); this.player.play(); - if((this.personal.group & 1 << ClientGroup.Leader._hx_index) != 0 && !this.player.isVideoLoaded()) { + if((this.personal.group & 2) != 0 && !this.player.isVideoLoaded()) { this.forceSyncNextTick = true; } break; diff --git a/src/Types.hx b/src/Types.hx index c791733..d16e58e 100644 --- a/src/Types.hx +++ b/src/Types.hx @@ -28,6 +28,7 @@ typedef Config = { }, emotes:Array<Emote>, filters:Array<Filter>, + ?isVerbose:Bool, ?salt:String }; diff --git a/src/client/Main.hx b/src/client/Main.hx index 76e1009..846acf6 100644 --- a/src/client/Main.hx +++ b/src/client/Main.hx @@ -319,9 +319,11 @@ class Main { function onMessage(e):Void { final data:WsEvent = Json.parse(e.data); - final t:String = cast data.type; - final t = t.charAt(0).toLowerCase() + t.substr(1); - trace('Event: ${data.type}', untyped data[t]); + if (config != null && config.isVerbose) { + final t:String = cast data.type; + final t = t.charAt(0).toLowerCase() + t.substr(1); + trace('Event: ${data.type}', Reflect.field(data, t)); + } switch (data.type) { case Connected: onConnected(data); diff --git a/src/server/Main.hx b/src/server/Main.hx index d5e8be6..3c85c3e 100644 --- a/src/server/Main.hx +++ b/src/server/Main.hx @@ -73,6 +73,7 @@ class Main { loadState(); config = loadUserConfig(); userList = loadUsers(); + config.isVerbose = verbose; config.salt = generateConfigSalt(); localIp = Utils.getLocalIp(); globalIp = localIp; |
