|
|
@ -250,7 +250,7 @@ class Request { |
|
|
|
|
|
|
|
relay (value, to, opts) { |
|
|
|
const socket = (opts && opts.socket) || this.socket |
|
|
|
const buffer = this._encodeRequest(null, value, socket) |
|
|
|
const buffer = this._encodeRequest(null, value, to, socket) |
|
|
|
socket.send(buffer, 0, buffer.byteLength, to.port, to.host) |
|
|
|
} |
|
|
|
|
|
|
@ -258,7 +258,7 @@ class Request { |
|
|
|
if (this.destroyed) return |
|
|
|
|
|
|
|
if (this.socket === null) return |
|
|
|
if (this._buffer === null) this._buffer = this._encodeRequest(this.token, this.value, this.socket) |
|
|
|
if (this._buffer === null) this._buffer = this._encodeRequest(this.token, this.value, this.to, this.socket) |
|
|
|
|
|
|
|
if (!force && this._io.congestion.isFull()) { |
|
|
|
this._io._pending.push(this) |
|
|
@ -323,7 +323,7 @@ class Request { |
|
|
|
socket.send(state.buffer, 0, state.buffer.byteLength, from.port, from.host, onflush) |
|
|
|
} |
|
|
|
|
|
|
|
_encodeRequest (token, value, socket) { |
|
|
|
_encodeRequest (token, value, to, socket) { |
|
|
|
const id = this._io.ephemeral === false && socket === this._io.serverSocket |
|
|
|
const state = { start: 0, end: 1 + 1 + 6 + 2, buffer: null } // (type | version) + flags + to + tid
|
|
|
|
|
|
|
@ -340,7 +340,7 @@ class Request { |
|
|
|
state.buffer[state.start++] = (id ? 1 : 0) | (token ? 2 : 0) | (this.target ? 4 : 0) | (value ? 8 : 0) |
|
|
|
|
|
|
|
c.uint16.encode(state, this.tid) |
|
|
|
peer.ipv4.encode(state, this.to) |
|
|
|
peer.ipv4.encode(state, to) |
|
|
|
|
|
|
|
if (id) c.fixed32.encode(state, this._io.table.id) |
|
|
|
if (token) c.fixed32.encode(state, token) |
|
|
|