Send current task to server. * @param {*} [timeout=-1] Optional timeout value in ms * @returns the response from the render request. * @memberof Task
(timeout = -1)
| 1056 | * @memberof Task |
| 1057 | */ |
| 1058 | async post(timeout = -1) { |
| 1059 | let jsonResponse = await super.post("/filter", timeout) |
| 1060 | if (typeof jsonResponse?.task !== "number") { |
| 1061 | console.warn("Endpoint error response: ", jsonResponse) |
| 1062 | const event = Object.assign({ task: this }, jsonResponse) |
| 1063 | await eventSource.fireEvent(EVENT_UNEXPECTED_RESPONSE, event) |
| 1064 | if ("continueWith" in event) { |
| 1065 | jsonResponse = await Promise.resolve(event.continueWith) |
| 1066 | } |
| 1067 | if (typeof jsonResponse?.task !== "number") { |
| 1068 | const err = new Error(jsonResponse?.detail || "Endpoint response does not contains a task ID.") |
| 1069 | this.abort(err) |
| 1070 | throw err |
| 1071 | } |
| 1072 | } |
| 1073 | this._setId(jsonResponse.task) |
| 1074 | if (jsonResponse.stream) { |
| 1075 | this.streamUrl = jsonResponse.stream |
| 1076 | } |
| 1077 | this._setStatus(TaskStatus.waiting) |
| 1078 | return jsonResponse |
| 1079 | } |
| 1080 | checkReqBody() { } |
| 1081 | enqueue(progressCallback) { |
| 1082 | return Task.enqueueNew(this, FilterTask, progressCallback) |