Ejemplo n.º 1
0
 private XhrReceiver(string url, AjaxObjectFactory ajaxObject)
 {
     Log.Debug($"{nameof(XhrReceiver)}: {url}");
     this._bufferPosition = 0;
     this._xo             = ajaxObject("POST", url, null);
     this._xo.On("chunk", this.ChunkHandler);
     this._xo.Once("finish", this.OnFinish);
 }
Ejemplo n.º 2
0
 public void Abort()
 {
     Log.Debug(nameof(this.Abort));
     if (this._xo != null)
     {
         this._xo.Close();
         Log.Debug($"{nameof(this.Abort)}: Close");
         this.Emit("close", null, "user");
         this._xo = null;
     }
     this.Cleanup();
 }
Ejemplo n.º 3
0
        private void OnFinish(object sender, object[] args)
        {
            var status = (int)args[0];
            var text   = args[1] as string;

            Log.Debug($"{nameof(this.OnFinish)}: Finish {status} {text}");
            this.ChunkHandler(this, status, text);
            this._xo = null;
            var reason = status == 200 ? "network" : "permanent";

            Log.Debug($"{nameof(this.OnFinish)}: Close {reason}");
            this.Emit("close", null, reason);
            this.Cleanup();
        }