mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-20 12:15:51 +00:00
JS: Hold requests until connection is established.
This will have to change when we add multiple server support, but it does the trick for now.
This commit is contained in:
@@ -161,11 +161,19 @@ Server.prototype.request = function (request)
|
||||
// Advance message ID
|
||||
this._id++;
|
||||
|
||||
if (this._remote.trace) {
|
||||
utils.logObject("server: request: %s", request.message);
|
||||
}
|
||||
if (this._state === "online" ||
|
||||
(request.message.command === "subscribe" && this._ws.readyState === 1)) {
|
||||
if (this._remote.trace) {
|
||||
utils.logObject("server: request: %s", request.message);
|
||||
}
|
||||
|
||||
this._ws.send(JSON.stringify(request.message));
|
||||
this._ws.send(JSON.stringify(request.message));
|
||||
} else {
|
||||
// XXX There are many ways to make this smarter.
|
||||
this.once('connect', function () {
|
||||
this._ws.send(JSON.stringify(request.message));
|
||||
});
|
||||
}
|
||||
} else {
|
||||
if (this._remote.trace) {
|
||||
utils.logObject("server: request: DROPPING: %s", request.message);
|
||||
|
||||
Reference in New Issue
Block a user