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

Method request

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

8027 * @returns {Promise} Response promise
8028 */
8029 request (value, timeout = 0) {
8030 let promise = new fbe.DeferredPromise()
8031 let current = Date.now()
8032
8033 // Send the request message
8034 let serialized = this.send(value)
8035 if (serialized > 0) {
8036 // Calculate the unique timestamp
8037 this._timestamp = (current <= this._timestamp) ? this._timestamp + 1 : current
8038
8039 // Register the request
8040 this._requests_by_id.set(value.id, [this._timestamp, timeout, promise])
8041 if (timeout > 0) {
8042 this._requests_by_timestamp.set(this._timestamp, value.id)
8043 }
8044 } else {
8045 promise.reject(new Error('Send request failed!'))
8046 }
8047
8048 return promise
8049 }
8050
8051 /**
8052 * Response value

Callers

nothing calls this directly

Calls 3

sendMethod · 0.95
setMethod · 0.45
rejectMethod · 0.45

Tested by

no test coverage detected