mirror of
https://github.com/fulpstation/fulpstation.git
synced 2025-12-10 10:01:40 +00:00
Replaces goonchat with a tgui based chat panel
Fixes #52898
Fixes #52663
It is as fast as goonchat was (if not faster in certain circumstances), and is very extensible. It has all the necessary code for sorting messages into categories, which means that one of the next features will be multiple tab support.
Additional features that you will get with tgchat right now:
Massively faster server-side performance compared to goonchat, especially if batching multiple messages to one client.
Message persistence across rounds and reconnects. (All messages are stored client-side in IndexedDB)
More robust scroll tracking. If you scroll up, it will not change the scroll position on new messages like goonchat did.
Multiple message combining. (Currently set to combine up to 5 messages over last 5 seconds).
If using the highlighting feature, it highlights the whole message as well as the matching word.
"Now playing" widget, with preview of the song title, a knob for adjusting the volume and a stop button.
Architecture is as following:
```
to_chat() -+
|
SSchat
(queue, batching)
|
window.send_message()
|
v
+-------------+
| tgui-panel |
|+-----------+|
|| tgchat ||
|+-----------+|
+-------------+
```
Subsystem is basically goonchat, but without all the garbage that slows the servers down (string concatenation, double urlencoding, sanitizing, etc). Now, instead of all that, it's being slowed down by json_encode in /datum/tgui_window/proc/send_message, which IMO is completely worth it, and allows sending various templates and widgets to tgchat.
/datum/tgui_window abstracts the whole window away from you, establishes a nice message-passing interface between DM and JS, with two message queues on each side, automatically loads js/css assets for you, basically does everything. You as a developer only have to worry about sending/receiving messages and write javascript.
tgui-panel is a slimmed down version of tgui, and functions as a container for various widgets, and tgchat is one of them. It of course can be expanded with more stuff.
It's also a separate entry point and a JS bundle, so it's not bloating the main tgui bundle, and is currently sitting at about 230kB.
103 lines
3.7 KiB
Plaintext
103 lines
3.7 KiB
Plaintext
#define PING_BUFFER_TIME 25
|
|
|
|
SUBSYSTEM_DEF(server_maint)
|
|
name = "Server Tasks"
|
|
wait = 6
|
|
flags = SS_POST_FIRE_TIMING
|
|
priority = FIRE_PRIORITY_SERVER_MAINT
|
|
init_order = INIT_ORDER_SERVER_MAINT
|
|
runlevels = RUNLEVEL_LOBBY | RUNLEVELS_DEFAULT
|
|
var/list/currentrun
|
|
var/cleanup_ticker = 0
|
|
|
|
/datum/controller/subsystem/server_maint/PreInit()
|
|
world.hub_password = "" //quickly! before the hubbies see us.
|
|
|
|
/datum/controller/subsystem/server_maint/Initialize(timeofday)
|
|
if (CONFIG_GET(flag/hub))
|
|
world.update_hub_visibility(TRUE)
|
|
return ..()
|
|
|
|
/datum/controller/subsystem/server_maint/fire(resumed = FALSE)
|
|
if(!resumed)
|
|
if(listclearnulls(GLOB.clients))
|
|
log_world("Found a null in clients list!")
|
|
src.currentrun = GLOB.clients.Copy()
|
|
|
|
switch (cleanup_ticker) // do only one of these at a time, once per 5 fires
|
|
if (0)
|
|
if(listclearnulls(GLOB.player_list))
|
|
log_world("Found a null in player_list!")
|
|
cleanup_ticker++
|
|
if (5)
|
|
if(listclearnulls(GLOB.mob_list))
|
|
log_world("Found a null in mob_list!")
|
|
cleanup_ticker++
|
|
if (10)
|
|
if(listclearnulls(GLOB.alive_mob_list))
|
|
log_world("Found a null in alive_mob_list!")
|
|
cleanup_ticker++
|
|
if (15)
|
|
if(listclearnulls(GLOB.suicided_mob_list))
|
|
log_world("Found a null in suicided_mob_list!")
|
|
cleanup_ticker++
|
|
if (20)
|
|
if(listclearnulls(GLOB.dead_mob_list))
|
|
log_world("Found a null in dead_mob_list!")
|
|
cleanup_ticker++
|
|
if (25)
|
|
cleanup_ticker = 0
|
|
else
|
|
cleanup_ticker++
|
|
|
|
var/list/currentrun = src.currentrun
|
|
var/round_started = SSticker.HasRoundStarted()
|
|
|
|
var/kick_inactive = CONFIG_GET(flag/kick_inactive)
|
|
var/afk_period
|
|
if(kick_inactive)
|
|
afk_period = CONFIG_GET(number/afk_period)
|
|
for(var/I in currentrun)
|
|
var/client/C = I
|
|
//handle kicking inactive players
|
|
if(round_started && kick_inactive && !C.holder && C.is_afk(afk_period))
|
|
var/cmob = C.mob
|
|
if (!isnewplayer(cmob) || !SSticker.queued_players.Find(cmob))
|
|
log_access("AFK: [key_name(C)]")
|
|
to_chat(C, "<span class='userdanger'>You have been inactive for more than [DisplayTimeText(afk_period)] and have been disconnected.</span><br><span class='danger'>You may reconnect via the button in the file menu or by <b><u><a href='byond://winset?command=.reconnect'>clicking here to reconnect</a></u></b>.</span>")
|
|
QDEL_IN(C, 1) //to ensure they get our message before getting disconnected
|
|
continue
|
|
|
|
if (!(!C || world.time - C.connection_time < PING_BUFFER_TIME || C.inactivity >= (wait-1)))
|
|
winset(C, null, "command=.update_ping+[world.time+world.tick_lag*TICK_USAGE_REAL/100]")
|
|
|
|
if (MC_TICK_CHECK) //one day, when ss13 has 1000 people per server, you guys are gonna be glad I added this tick check
|
|
return
|
|
|
|
/datum/controller/subsystem/server_maint/Shutdown()
|
|
kick_clients_in_lobby("<span class='boldannounce'>The round came to an end with you in the lobby.</span>", TRUE) //second parameter ensures only afk clients are kicked
|
|
var/server = CONFIG_GET(string/server)
|
|
for(var/thing in GLOB.clients)
|
|
if(!thing)
|
|
continue
|
|
var/client/C = thing
|
|
C?.tgui_panel?.send_roundrestart()
|
|
if(server) //if you set a server location in config.txt, it sends you there instead of trying to reconnect to the same world address. -- NeoFite
|
|
C << link("byond://[server]")
|
|
var/datum/tgs_version/tgsversion = world.TgsVersion()
|
|
if(tgsversion)
|
|
SSblackbox.record_feedback("text", "server_tools", 1, tgsversion.raw_parameter)
|
|
|
|
|
|
/datum/controller/subsystem/server_maint/proc/UpdateHubStatus()
|
|
if(!CONFIG_GET(flag/hub) || !CONFIG_GET(number/max_hub_pop))
|
|
return FALSE //no point, hub / auto hub controls are disabled
|
|
|
|
var/max_pop = CONFIG_GET(number/max_hub_pop)
|
|
|
|
if(GLOB.clients.len > max_pop)
|
|
world.update_hub_visibility(FALSE)
|
|
else
|
|
world.update_hub_visibility(TRUE)
|
|
#undef PING_BUFFER_TIME
|