forked from BeeStation/NSV13
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
596 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/datum/config_entry/keyed_list/external_rsc_urls | ||
key_mode = KEY_MODE_TEXT | ||
value_mode = VALUE_MODE_FLAG | ||
|
||
/datum/config_entry/flag/asset_simple_preload | ||
|
||
/datum/config_entry/string/asset_transport | ||
/datum/config_entry/string/asset_transport/ValidateAndSet(str_val) | ||
return (lowertext(str_val) in list("simple", "webroot")) && ..(lowertext(str_val)) | ||
|
||
/datum/config_entry/string/asset_cdn_webroot | ||
protection = CONFIG_ENTRY_LOCKED | ||
|
||
/datum/config_entry/string/asset_cdn_webroot/ValidateAndSet(str_var) | ||
if (!str_var || trim(str_var) == "") | ||
return FALSE | ||
if (str_var && str_var[length(str_var)] != "/") | ||
str_var += "/" | ||
return ..(str_var) | ||
|
||
/datum/config_entry/string/asset_cdn_url | ||
protection = CONFIG_ENTRY_LOCKED | ||
default = null | ||
|
||
/datum/config_entry/string/asset_cdn_url/ValidateAndSet(str_var) | ||
if (!str_var || trim(str_var) == "") | ||
return FALSE | ||
if (str_var && str_var[length(str_var)] != "/") | ||
str_var += "/" | ||
return ..(str_var) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
|
||
/// Process asset cache client topic calls for "asset_cache_confirm_arrival=[INT]" | ||
/client/proc/asset_cache_confirm_arrival(job_id) | ||
var/asset_cache_job = round(text2num(job_id)) | ||
//because we skip the limiter, we have to make sure this is a valid arrival and not somebody tricking us into letting them append to a list without limit. | ||
if (asset_cache_job > 0 && asset_cache_job <= last_asset_job && !(completed_asset_jobs["[asset_cache_job]"])) | ||
completed_asset_jobs["[asset_cache_job]"] = TRUE | ||
last_completed_asset_job = max(last_completed_asset_job, asset_cache_job) | ||
else | ||
return asset_cache_job || TRUE | ||
|
||
|
||
/// Process asset cache client topic calls for "asset_cache_preload_data=[HTML+JSON_STRING] | ||
/client/proc/asset_cache_preload_data(data) | ||
var/json = data | ||
var/list/preloaded_assets = json_decode(json) | ||
|
||
for (var/preloaded_asset in preloaded_assets) | ||
if (copytext(preloaded_asset, findlasttext(preloaded_asset, ".")+1) in list("js", "jsm", "htm", "html")) | ||
preloaded_assets -= preloaded_asset | ||
continue | ||
sent_assets |= preloaded_assets | ||
|
||
|
||
/// Updates the client side stored json file used to keep track of what assets the client has between restarts/reconnects. | ||
/client/proc/asset_cache_update_json() | ||
if (world.time - connection_time < 10 SECONDS) //don't override the existing data file on a new connection | ||
return | ||
|
||
src << browse(json_encode(sent_assets), "file=asset_data.json&display=0") | ||
|
||
/// Blocks until all currently sending browse and browse_rsc assets have been sent. | ||
/// Due to byond limitations, this proc will sleep for 1 client round trip even if the client has no pending asset sends. | ||
/// This proc will return an untrue value if it had to return before confirming the send, such as timeout or the client going away. | ||
/client/proc/browse_queue_flush(timeout = 50) | ||
var/job = ++last_asset_job | ||
var/t = 0 | ||
var/timeout_time = timeout | ||
src << browse({"<script>window.location.href="?asset_cache_confirm_arrival=[job]"</script>"}, "window=asset_cache_browser&file=asset_cache_send_verify.htm") | ||
|
||
while(!completed_asset_jobs["[job]"] && t < timeout_time) // Reception is handled in Topic() | ||
stoplag(1) // Lock up the caller until this is received. | ||
t++ | ||
if (t < timeout_time) | ||
return TRUE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/** | ||
* # asset_cache_item | ||
* | ||
* An internal datum containing info on items in the asset cache. Mainly used to cache md5 info for speed. | ||
*/ | ||
/datum/asset_cache_item | ||
var/name | ||
var/hash | ||
var/resource | ||
var/ext = "" | ||
/// Should this file alsobut be sent via the legacy browse_rsc system | ||
/// when cdn transports are enabled? | ||
var/legacy = FALSE | ||
/// Used by the cdn system to keep legacy css assets with their parent | ||
/// css file. (css files resolve urls relative to the css file, so the | ||
/// legacy system can't be used if the css file itself could go out over | ||
/// the cdn) | ||
var/namespace = null | ||
/// True if this is the parent css or html file for an asset's namespace | ||
var/namespace_parent = FALSE | ||
/// TRUE for keeping local asset names when browse_rsc backend is used | ||
var/keep_local_name = FALSE | ||
|
||
/datum/asset_cache_item/New(name, file) | ||
if (!isfile(file)) | ||
file = fcopy_rsc(file) | ||
hash = md5(file) | ||
if (!hash) | ||
hash = md5(fcopy_rsc(file)) | ||
if (!hash) | ||
CRASH("invalid asset sent to asset cache") | ||
debug_world_log("asset cache unexpected success of second fcopy_rsc") | ||
src.name = name | ||
var/extstart = findlasttext(name, ".") | ||
if (extstart) | ||
ext = ".[copytext(name, extstart+1)]" | ||
resource = file | ||
|
||
/datum/asset_cache_item/vv_edit_var(var_name, var_value) | ||
return FALSE | ||
|
||
/datum/asset_cache_item/CanProcCall(procname) | ||
return FALSE |
Oops, something went wrong.