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

Method request

projects/JavaScript/proto/test.js:24960–24980  ·  view source on GitHub ↗

* Request value * @this {!Client} * @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

24958 * @returns {Promise} Response promise
24959 */
24960 request (value, timeout = 0) {
24961 let promise = new fbe.DeferredPromise()
24962 let current = Date.now()
24963
24964 // Send the request message
24965 let serialized = this.send(value)
24966 if (serialized > 0) {
24967 // Calculate the unique timestamp
24968 this._timestamp = (current <= this._timestamp) ? this._timestamp + 1 : current
24969
24970 // Register the request
24971 this._requests_by_id.set(value.id, [this._timestamp, timeout, promise])
24972 if (timeout > 0) {
24973 this._requests_by_timestamp.set(this._timestamp, value.id)
24974 }
24975 } else {
24976 promise.reject(new Error('Send request failed!'))
24977 }
24978
24979 return promise
24980 }
24981
24982 /**
24983 * Response value

Callers

nothing calls this directly

Calls 3

sendMethod · 0.95
setMethod · 0.45
rejectMethod · 0.45

Tested by

no test coverage detected