Commit 6eaa154c139d73b65498f0c9648613df3d23ee44
send status messages
cel committed on 7/15/2017, 7:47:06 PMParent: 14c89af8a6ac540abbb7936e49a5e70e4c474a2b
Files changed
dat.dpi | changed |
dat.dpi | |||
---|---|---|---|
@@ -98,8 +98,12 @@ | |||
98 | 98 … | DpiReq.prototype.reload = function (url) { | |
99 | 99 … | this.socket.end("<cmd='reload_request' url='" + url + "' '>") | |
100 | 100 … | } | |
101 | 101 … | ||
102 … | +DpiReq.prototype.sendStatus = function (msg) { | ||
103 … | + this.socket.write("<cmd='send_status_message' msg='" + msg + "' '>") | ||
104 … | +} | ||
105 … | + | ||
102 | 106 … | DpiReq.prototype.writeHeader = function (type) { | |
103 | 107 … | this.socket.write("<cmd='start_send_page' url='" + this.url + "' '>") | |
104 | 108 … | this.socket.write('Content-type: ' + type + '\r\n\r\n') | |
105 | 109 … | } | |
@@ -273,14 +277,16 @@ | |||
273 | 277 … | DpiReq.prototype.serveDashboard = function () { | |
274 | 278 … | var self = this | |
275 | 279 … | var q = self.urlp.query | |
276 | 280 … | if (q.unswarm) { | |
281 … | + self.sendStatus('unswarming ' + q.key) | ||
277 | 282 … | return unswarm(q.key, function (err) { | |
278 | 283 … | if (err) return self.serveError(err) | |
279 | 284 … | return self.reload(q.reload) | |
280 | 285 … | }) | |
281 | 286 … | } | |
282 | 287 … | if (q.restart) { | |
288 … | + self.sendStatus('restarting') | ||
283 | 289 … | self.reload(q.reload) | |
284 | 290 … | return process.exit(0) | |
285 | 291 … | } | |
286 | 292 … | ||
@@ -328,17 +334,20 @@ | |||
328 | 334 … | DpiReq.prototype.serveDat = function () { | |
329 | 335 … | var self = this | |
330 | 336 … | self.urlp = parseDatUrl(self.url, true) | |
331 | 337 … | if (!self.urlp.host) return self.serveError('Archive not found') | |
338 … | + self.sendStatus('resolving name') | ||
332 | 339 … | datDns.resolveName(self.urlp.host, {ignoreCachedMiss: true}, function (err, key) { | |
333 | 340 … | if (err) return self.serveError(err) | |
334 | 341 … | if (!key) return cb(new TypeError('resolve failed')) | |
342 … | + self.sendStatus('getting archive') | ||
335 | 343 … | withTimeout(getArchive, 10000)(key, function (err, archive) { | |
336 | 344 … | if (err) return self.serveError(err) | |
337 | 345 … | if (!archive) return self.serveTimedout(self.urlp) | |
338 | 346 … | try { if (self.urlp.version) archive = archive.checkout(+self.urlp.version) } | |
339 | 347 … | catch(e) { return self.serveError(err) } | |
340 | 348 … | self.archive = archive | |
349 … | + self.sendStatus('serving file') | ||
341 | 350 … | self.serve() | |
342 | 351 … | }) | |
343 | 352 … | }) | |
344 | 353 … | } |
Built with git-ssb-web