public TargetsService(XMLHttpRequest xmlHttpRequest, ServiceConfig config, TargetsParser targets) : base(xmlHttpRequest) { this.config = config; this.targets = targets; this.url = "assets/data/targets.txt"; }
public byte[] LoadBinary(string path) { var xhr = new XMLHttpRequest(); xhr.open("GET", path, false); xhr.responseType = "arraybuffer"; if (xhr.responseType != "arraybuffer") { // use VB Loader to load binary array dynamic vbArr = VbAjaxLoader("GET", path); var fileContents = vbArr.toArray(); // decode byte array to string var data = new StringBuilder(); var i = 0; while (i < (fileContents.length - 1)) { data.AppendChar((char)(fileContents[i])); i++; } var reader = GetBytesFromString(data.ToString()); return reader; } xhr.send(); if (xhr.status == 200) { var reader = NewUint8Array(xhr.response); return reader; } // Error handling if (xhr.status == 0) { throw new FileLoadException("You are offline!!\n Please Check Your Network."); } if (xhr.status == 404) { throw new FileLoadException("Requested URL not found."); } if (xhr.status == 500) { throw new FileLoadException("Internel Server Error."); } if (xhr.statusText == "parsererror") { throw new FileLoadException("Error.\nParsing JSON Request failed."); } if (xhr.statusText == "timeout") { throw new FileLoadException("Request Time out."); } throw new FileLoadException("Unknow Error: " + xhr.responseText); }
public JsString synchronousLoad(JsString fragmentURL) { //We need to check to see if we already have this content. If we do not, then we need to load it now and insert it into the DOM var request = new XMLHttpRequest(); request.open("GET", fragmentURL, false); request.send(""); if (request.status == 404) { throw new JsError("Cannot continue, missing required content " + fragmentURL); } return request.responseText; }
public void Load() { var request = new XMLHttpRequest(); request.open(Method, Url, true); request.responseType = "arraybuffer"; request.onload = e => { var buffer = NewUint8Array(request.response); if (buffer != null) { FireComplete(buffer); } }; request.onerror = e => { Logger.Error("Loading failed: " + e.message); }; request.onprogress = e => { FireProgress(e.loaded, e.total); }; request.send(); }
public void LoadBinaryAsync(string path, Action<byte[]> success, Action<Exception> error) { var xhr = new XMLHttpRequest(); xhr.open("GET", path); xhr.responseType = "arraybuffer"; xhr.onreadystatechange = e => { if (xhr.readyState == 4) { if (xhr.status == 200) { var reader = NewUint8Array(xhr.response); success(reader); } // Error handling else if (xhr.status == 0) { error(new FileLoadException("You are offline!!\n Please Check Your Network.")); } else if (xhr.status == 404) { error(new FileLoadException("Requested URL not found.")); } else if (xhr.status == 500) { error(new FileLoadException("Internel Server Error.")); } else if (xhr.statusText == "parsererror") { error(new FileLoadException("Error.\nParsing JSON Request failed.")); } else if (xhr.statusText == "timeout") { error(new FileLoadException("Request Time out.")); } else { error(new FileLoadException("Unknow Error: " + xhr.responseText)); } } }; xhr.open("GET", path, true); xhr.responseType = "arraybuffer"; // IE fallback if (xhr.responseType != "arraybuffer") { // use VB Loader to load binary array dynamic vbArr = VbAjaxLoader("GET", path); var fileContents = vbArr.toArray(); // decode byte array to string var data = new StringBuilder(); var i = 0; while (i < (fileContents.length - 1)) { data.Append(((char)(fileContents[i]))); i++; } var reader = GetBytesFromString(data.ToString()); success(reader); return; } xhr.send(); }
public ContentLoader( ContentCache contentCache, XMLHttpRequest xmlHttpRequest ) : base(xmlHttpRequest) { this.contentCache = contentCache; }
protected virtual void modifyHeaders( XMLHttpRequest request ) { }
protected AbstractService( XMLHttpRequest xmlHttpRequest) { this.xmlHttpRequest = xmlHttpRequest; }
public SynchronousClassLoader(XMLHttpRequest xmlHttpRequest, JsString dynamicClassBaseUrl) { this.xmlHttpRequest = xmlHttpRequest; this.dynamicClassBaseUrl = dynamicClassBaseUrl; }
/* * * We dont need this right now but keeping the code cause we might need it again someday soon JsString correctPaths(JsString sheet, JsString urlPrefix) { //First, fix the path of any objects in the system. This fines url references and preprends paths //Right now this just works for relative urls, I am going to need to fix it for absolute //Now using this one instead for optional quotes //(url\s?\(\s?['"]?)([\w\W]*?)(['"]?\s?\)) var pathReplace = new JsRegExp("(url\\s?\\(\\s?[\'\"]?)([\\w\\W]*?)([\'\"]?\\s?\\))", "g"); JsString replacementString = "$1" + urlPrefix + "/$2$3"; sheet = sheet.replace(pathReplace, replacementString); return sheet; }*/ void resolveSheet(JsString url) { var sheetRequest = new XMLHttpRequest(); JsString behaviorSheet = ""; JsString prefix; sheetRequest.open("GET", url, false); sheetRequest.send(""); if (sheetRequest.status == 404) { throw new JsError("Cannot Find StyleSheet " + url); } int lastSlash = url.lastIndexOf("/"); prefix = url.substring(0, lastSlash); parseAndPersistBehaviors(sheetRequest.responseText); }
private void makeAsynchronousRequest(JsString url, TranslationsFileLoaded fileLoaded ) { XMLHttpRequest request = new XMLHttpRequest(); if (forceReload) { //just bust the cache for now url = url + "?rnd=" + JsMath.random(); } request.open("GET", url, true); request.onreadystatechange = delegate(DOMEvent evt) { if ( request.readyState == 4 && request.status == 200 ) { parseResult( request.responseText ); fileLoaded(); } else if ( request.readyState >= 3 && request.status == 404 ) { HtmlContext.alert( "Required Content " + url + " cannot be loaded." ); throw new JsError( "Cannot continue, missing required property file " + url ); } }; request.send(""); }
private void makeSynchronousRequest(JsString url) { XMLHttpRequest request = new XMLHttpRequest(); if (forceReload) { //just bust the cache for now url = url + "?rnd=" + JsMath.random(); } request.open("GET", url, false); request.send(""); if (request.status == 404) { HtmlContext.alert("Required Content " + url + " cannot be loaded."); throw new JsError("Cannot continue, missing required property file " + url); } parseResult(request.responseText); }