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

Method request

projects/JavaScript/proto/test.js:25372–25392  ·  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

25370 * @returns {Promise} Response promise
25371 */
25372 request (value, timeout = 0) {
25373 let promise = new fbe.DeferredPromise()
25374 let current = Date.now()
25375
25376 // Send the request message
25377 let serialized = this.send(value)
25378 if (serialized > 0) {
25379 // Calculate the unique timestamp
25380 this._timestamp = (current <= this._timestamp) ? this._timestamp + 1 : current
25381
25382 // Register the request
25383 this._requests_by_id.set(value.id, [this._timestamp, timeout, promise])
25384 if (timeout > 0) {
25385 this._requests_by_timestamp.set(this._timestamp, value.id)
25386 }
25387 } else {
25388 promise.reject(new Error('Send request failed!'))
25389 }
25390
25391 return promise
25392 }
25393
25394 /**
25395 * Response value

Callers

nothing calls this directly

Calls 3

sendMethod · 0.95
setMethod · 0.45
rejectMethod · 0.45

Tested by

no test coverage detected