add support for unsupported attribute close code and remove SAVE_MESSAGES

This commit is contained in:
hippoz 2021-10-03 21:18:51 +03:00
parent 918a34f882
commit 02665902ff
No known key found for this signature in database
GPG key ID: 7C52899193467641
2 changed files with 3 additions and 3 deletions

View file

@ -60,7 +60,7 @@ class GatewayConnection {
} }
} }
GatewayConnection.prototype.connect = function(token, attributes=["PRESENCE_UPDATES", "SAVE_MESSAGES"]) { GatewayConnection.prototype.connect = function(token, attributes=["PRESENCE_UPDATES"]) {
if (token) this.token = token; if (token) this.token = token;
if (this.token) token = this.token; if (this.token) token = this.token;

View file

@ -18,6 +18,7 @@ const wsCloseCodes = {
NOT_AUTHORIZED: [4006, "Not authorized"], NOT_AUTHORIZED: [4006, "Not authorized"],
FLOODING: [4007, "Flooding"], FLOODING: [4007, "Flooding"],
NO_PING: [4008, "No ping"], NO_PING: [4008, "No ping"],
UNSUPPORTED_ATTRIBUTE: [4009, "Unsupported attribute."],
}; };
const cancelReconnectionForCodes = [ const cancelReconnectionForCodes = [
wsCloseCodes.NOT_AUTHENTICATED[0], wsCloseCodes.NOT_AUTHENTICATED[0],
@ -25,6 +26,7 @@ const cancelReconnectionForCodes = [
wsCloseCodes.SERVER_DENIED_CONNECTION[0], wsCloseCodes.SERVER_DENIED_CONNECTION[0],
wsCloseCodes.TOO_MANY_SESSIONS[0], wsCloseCodes.TOO_MANY_SESSIONS[0],
wsCloseCodes.FLOODING[0], wsCloseCodes.FLOODING[0],
wsCloseCodes.UNSUPPORTED_ATTRIBUTE[0],
]; ];
globalGatewayConnection.onopen = (sessionData) => { globalGatewayConnection.onopen = (sessionData) => {
@ -86,6 +88,4 @@ globalGatewayConnection.onclose = function(code) {
}, 5000); }, 5000);
}; };
window.___gateway = globalGatewayConnection;
export default globalGatewayConnection; export default globalGatewayConnection;