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

Method request

projects/JavaScript/proto/enums.js:7944–7964  ·  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

7942 * @returns {Promise} Response promise
7943 */
7944 request (value, timeout = 0) {
7945 let promise = new fbe.DeferredPromise()
7946 let current = Date.now()
7947
7948 // Send the request message
7949 let serialized = this.send(value)
7950 if (serialized > 0) {
7951 // Calculate the unique timestamp
7952 this._timestamp = (current <= this._timestamp) ? this._timestamp + 1 : current
7953
7954 // Register the request
7955 this._requests_by_id.set(value.id, [this._timestamp, timeout, promise])
7956 if (timeout > 0) {
7957 this._requests_by_timestamp.set(this._timestamp, value.id)
7958 }
7959 } else {
7960 promise.reject(new Error('Send request failed!'))
7961 }
7962
7963 return promise
7964 }
7965
7966 /**
7967 * Response value

Callers

nothing calls this directly

Calls 3

sendMethod · 0.95
setMethod · 0.45
rejectMethod · 0.45

Tested by

no test coverage detected