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

Method request

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

7010 * @returns {Promise} Response promise
7011 */
7012 request (value, timeout = 0) {
7013 let promise = new fbe.DeferredPromise()
7014 let current = Date.now()
7015
7016 // Send the request message
7017 let serialized = this.send(value)
7018 if (serialized > 0) {
7019 // Calculate the unique timestamp
7020 this._timestamp = (current <= this._timestamp) ? this._timestamp + 1 : current
7021
7022 // Register the request
7023 this._requests_by_id.set(value.id, [this._timestamp, timeout, promise])
7024 if (timeout > 0) {
7025 this._requests_by_timestamp.set(this._timestamp, value.id)
7026 }
7027 } else {
7028 promise.reject(new Error('Send request failed!'))
7029 }
7030
7031 return promise
7032 }
7033
7034 /**
7035 * Response value

Callers

nothing calls this directly

Calls 3

sendMethod · 0.95
setMethod · 0.45
rejectMethod · 0.45

Tested by

no test coverage detected