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

Method request

projects/JavaScript/proto/protoex.js:7263–7283  ·  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

7261 * @returns {Promise} Response promise
7262 */
7263 request (value, timeout = 0) {
7264 let promise = new fbe.DeferredPromise()
7265 let current = Date.now()
7266
7267 // Send the request message
7268 let serialized = this.send(value)
7269 if (serialized > 0) {
7270 // Calculate the unique timestamp
7271 this._timestamp = (current <= this._timestamp) ? this._timestamp + 1 : current
7272
7273 // Register the request
7274 this._requests_by_id.set(value.id, [this._timestamp, timeout, promise])
7275 if (timeout > 0) {
7276 this._requests_by_timestamp.set(this._timestamp, value.id)
7277 }
7278 } else {
7279 promise.reject(new Error('Send request failed!'))
7280 }
7281
7282 return promise
7283 }
7284
7285 /**
7286 * Response value

Callers

nothing calls this directly

Calls 3

sendMethod · 0.95
setMethod · 0.45
rejectMethod · 0.45

Tested by

no test coverage detected