mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2026-08-30 16:48:12 +01:00
Some VChat Tweaks
- Chat remains between client reconnects if your client didn't close (so things like using the reconnect button, or autoreconnects at round end when that feels like working) - The client doesn't send pings to the server, the server sends pings to the client. This fixes AFK measurements for AFK kick purposes. - Turn latency indicator into a green/red indicator to show if you're connected, and when clicked will perform a one-time ping (and block doing it again for 10 seconds). It will display '?ms' if it never got a reply, or '999ms' if it did, but it was over 1s.
This commit is contained in:
@@ -46,7 +46,6 @@ GLOBAL_DATUM_INIT(iconCache, /savefile, new("data/iconCache.sav")) //Cache of ic
|
||||
. = ..()
|
||||
|
||||
owner = C
|
||||
update_vis()
|
||||
|
||||
/datum/chatOutput/Destroy()
|
||||
owner = null
|
||||
@@ -78,14 +77,20 @@ GLOBAL_DATUM_INIT(iconCache, /savefile, new("data/iconCache.sav")) //Cache of ic
|
||||
become_broken()
|
||||
return FALSE
|
||||
|
||||
//Could be loaded from a previous round, are you still there?
|
||||
if(winget(owner,"outputwindow.htmloutput","is-visible") == "true") //Winget returns strings
|
||||
send_event(event = list("evttype" = "availability"))
|
||||
sleep(3 SECONDS)
|
||||
|
||||
if(!owner) // In case the client vanishes before winexists returns
|
||||
qdel(src)
|
||||
return FALSE
|
||||
|
||||
if(!resources_sent)
|
||||
send_resources()
|
||||
|
||||
load()
|
||||
if(!loaded)
|
||||
update_vis()
|
||||
if(!resources_sent)
|
||||
send_resources()
|
||||
load()
|
||||
|
||||
return TRUE
|
||||
|
||||
@@ -115,7 +120,7 @@ GLOBAL_DATUM_INIT(iconCache, /savefile, new("data/iconCache.sav")) //Cache of ic
|
||||
owner.chatOutputLoadedAt = world.time
|
||||
|
||||
//update_vis() //It does it's own winsets
|
||||
|
||||
ping_cycle()
|
||||
send_playerinfo()
|
||||
load_database()
|
||||
|
||||
@@ -163,9 +168,23 @@ GLOBAL_DATUM_INIT(iconCache, /savefile, new("data/iconCache.sav")) //Cache of ic
|
||||
/datum/chatOutput/proc/send_event(var/event, var/client/C = owner)
|
||||
C << output(jsEncode(event), "htmloutput:get_event")
|
||||
|
||||
//Looping sleeping proc that just pings the client and dies when we die
|
||||
/datum/chatOutput/proc/ping_cycle()
|
||||
set waitfor = FALSE
|
||||
while(!QDELING(src))
|
||||
if(!owner)
|
||||
qdel(src)
|
||||
return
|
||||
send_event(event = keep_alive())
|
||||
sleep(20 SECONDS) //Make sure this makes sense with what the js client is expecting
|
||||
|
||||
//Just produces a message for using in keepalives from the server to the client
|
||||
/datum/chatOutput/proc/keepalive()
|
||||
return list("evttype" = "keepalive_server")
|
||||
/datum/chatOutput/proc/keep_alive()
|
||||
return list("evttype" = "keepalive")
|
||||
|
||||
//A response to a latency check from the client
|
||||
/datum/chatOutput/proc/latency_check()
|
||||
return list("evttype" = "pong")
|
||||
|
||||
//Redirected from client/Topic when the user clicks a link that pertains directly to the chat (when src == "chat")
|
||||
/datum/chatOutput/Topic(var/href, var/list/href_list)
|
||||
@@ -197,8 +216,8 @@ GLOBAL_DATUM_INIT(iconCache, /savefile, new("data/iconCache.sav")) //Cache of ic
|
||||
CRASH("Tried to send a message to [owner.ckey] chatOutput before it was ready!")
|
||||
if("done_loading")
|
||||
data = done_loading(arglist(params))
|
||||
if("keepalive_client")
|
||||
data = keepalive(arglist(params))
|
||||
if("ping")
|
||||
data = latency_check(arglist(params))
|
||||
if("ident")
|
||||
data = bancheck(arglist(params))
|
||||
if("unloading")
|
||||
|
||||
Reference in New Issue
Block a user