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

Method request

projects/JavaScript/proto/proto.js:7689–7709  ·  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

7687 * @returns {Promise} Response promise
7688 */
7689 request (value, timeout = 0) {
7690 let promise = new fbe.DeferredPromise()
7691 let current = Date.now()
7692
7693 // Send the request message
7694 let serialized = this.send(value)
7695 if (serialized > 0) {
7696 // Calculate the unique timestamp
7697 this._timestamp = (current <= this._timestamp) ? this._timestamp + 1 : current
7698
7699 // Register the request
7700 this._requests_by_id.set(value.id, [this._timestamp, timeout, promise])
7701 if (timeout > 0) {
7702 this._requests_by_timestamp.set(this._timestamp, value.id)
7703 }
7704 } else {
7705 promise.reject(new Error('Send request failed!'))
7706 }
7707
7708 return promise
7709 }
7710
7711 /**
7712 * Response value

Callers

nothing calls this directly

Calls 3

sendMethod · 0.95
setMethod · 0.45
rejectMethod · 0.45

Tested by

no test coverage detected