MCPcopy Create free account
hub / github.com/chronoxor/FastBinaryEncoding / request

Method request

projects/JavaScript/proto/enums.js:8267–8287  ·  view source on GitHub ↗

* Request value * @this {!FinalClient} * @param {!object} value Value to request * @param {!number} timeout Timeout in milliseconds (default is 0) * @returns {Promise} Response promise

(value, timeout = 0)

Source from the content-addressed store, hash-verified

8265 * @returns {Promise} Response promise
8266 */
8267 request (value, timeout = 0) {
8268 let promise = new fbe.DeferredPromise()
8269 let current = Date.now()
8270
8271 // Send the request message
8272 let serialized = this.send(value)
8273 if (serialized > 0) {
8274 // Calculate the unique timestamp
8275 this._timestamp = (current <= this._timestamp) ? this._timestamp + 1 : current
8276
8277 // Register the request
8278 this._requests_by_id.set(value.id, [this._timestamp, timeout, promise])
8279 if (timeout > 0) {
8280 this._requests_by_timestamp.set(this._timestamp, value.id)
8281 }
8282 } else {
8283 promise.reject(new Error('Send request failed!'))
8284 }
8285
8286 return promise
8287 }
8288
8289 /**
8290 * Response value

Callers

nothing calls this directly

Calls 3

sendMethod · 0.95
setMethod · 0.45
rejectMethod · 0.45

Tested by

no test coverage detected