From c89baf1e29fa4ae4e46ae2c40bb6ab7bcafb7323 Mon Sep 17 00:00:00 2001 From: Endel Dreyer Date: Thu, 2 Nov 2017 02:52:32 -0200 Subject: [PATCH] fix setting WebSocket binaryType on reconnections. gamestdio/colyseus#62 --- dist/colyseus.js | 9 +++++---- dist/index.html | 5 +++++ package.json | 4 ++-- src/Room.ts | 2 +- src/index.ts | 1 + 5 files changed, 14 insertions(+), 7 deletions(-) diff --git a/dist/colyseus.js b/dist/colyseus.js index 2e4e279..25f2e51 100644 --- a/dist/colyseus.js +++ b/dist/colyseus.js @@ -4204,7 +4204,7 @@ var Room = /** @class */ (function (_super) { var _this = this; this.connection = connection; this.connection.onmessage = this.onMessageCallback.bind(this); - this.connection.onclose = function (e) { return _this.onLeave.dispatch(); }; + this.connection.onclose = function (e) { return _this.onLeave.dispatch(e); }; }; Room.prototype.onMessageCallback = function (event) { var message = msgpack.decode(new Uint8Array(event.data)); @@ -7030,12 +7030,13 @@ exports.Connection = Connection; Object.defineProperty(exports,"__esModule",{value:true});var _createClass=function(){function defineProperties(target,props){for(var i=0;i2&&arguments[2]!==undefined?arguments[2]:{};_classCallCheck(this,WebSocketClient);this.url=url;this.protocols=protocols;this.reconnectEnabled=true;this.listeners={};this.backoff=createBackoff(options.backoff||'exponential',options);this.backoff.onReady=this.onBackoffReady.bind(this);this.open();}_createClass(WebSocketClient,[{key:'open',value:function open(){var reconnect=arguments.length>0&&arguments[0]!==undefined?arguments[0]:false;this.isReconnect=reconnect;this.ws=new WebSocket(this.url,this.protocols);this.ws.onclose=this.onCloseCallback.bind(this);this.ws.onerror=this.onErrorCallback.bind(this);this.ws.onmessage=this.onMessageCallback.bind(this);this.ws.onopen=this.onOpenCallback.bind(this);}/** + */function WebSocketClient(url,protocols){var options=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{};_classCallCheck(this,WebSocketClient);this.url=url;this.protocols=protocols;this.reconnectEnabled=true;this.listeners={};this.backoff=createBackoff(options.backoff||'exponential',options);this.backoff.onReady=this.onBackoffReady.bind(this);this.open();}_createClass(WebSocketClient,[{key:'open',value:function open(){var reconnect=arguments.length>0&&arguments[0]!==undefined?arguments[0]:false;this.isReconnect=reconnect;// keep binaryType used on previous WebSocket connection +var binaryType=this.ws&&this.ws.binaryType;this.ws=new WebSocket(this.url,this.protocols);this.ws.onclose=this.onCloseCallback.bind(this);this.ws.onerror=this.onErrorCallback.bind(this);this.ws.onmessage=this.onMessageCallback.bind(this);this.ws.onopen=this.onOpenCallback.bind(this);if(binaryType){this.ws.binaryType=binaryType;}}/** * @ignore */},{key:'onBackoffReady',value:function onBackoffReady(number,delay){// console.log("onBackoffReady", number + ' ' + delay + 'ms'); this.open(true);}/** * @ignore - */},{key:'onCloseCallback',value:function onCloseCallback(){if(!this.isReconnect&&this.listeners['onclose']){this.listeners['onclose'].apply(null,arguments);}if(this.reconnectEnabled){this.backoff.backoff();}}/** + */},{key:'onCloseCallback',value:function onCloseCallback(e){if(!this.isReconnect&&this.listeners['onclose']){this.listeners['onclose'].apply(null,arguments);}if(this.reconnectEnabled&&e.code<3000){this.backoff.backoff();}}/** * @ignore */},{key:'onErrorCallback',value:function onErrorCallback(){if(this.listeners['onerror']){this.listeners['onerror'].apply(null,arguments);}}/** * @ignore @@ -7112,4 +7113,4 @@ Object.defineProperty(exports,"__esModule",{value:true});exports.createBackoff=c /***/ }) /******/ ]); -//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly8vd2VicGFjay9ib290c3RyYXAgOGQzNTc0MWMzODY2ZTFhZTk4MTYiLCJ3ZWJwYWNrOi8vLy4vbm9kZV9tb2R1bGVzL21zZ3BhY2stbGl0ZS9saWIvYnVmZmVyaXNoLmpzIiwid2VicGFjazovLy8uL25vZGVfbW9kdWxlcy9pc2FycmF5L2luZGV4LmpzIiwid2VicGFjazovLy8uL25vZGVfbW9kdWxlcy9tc2dwYWNrLWxpdGUvbGliL2NvZGVj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uZXIgcHJvcGVydHkuXG4gICAgICogICAgICAgICAgUmV0dXJucyBudWxsIGlmIG5vIHN1Y2ggSVNsb3QgaW5zdGFuY2UgZXhpc3RzIG9yIHRoZSBsaXN0IGlzIGVtcHR5LlxuICAgICAqL1xuICAgIFNsb3RMaXN0LnByb3RvdHlwZS5maW5kID0gZnVuY3Rpb24gKGxpc3RlbmVyKSB7XG4gICAgICAgIGlmICghdGhpcy5ub25FbXB0eSlcbiAgICAgICAgICAgIHJldHVybiBudWxsO1xuICAgICAgICB2YXIgcCA9IHRoaXM7XG4gICAgICAgIHdoaWxlIChwLm5vbkVtcHR5KSB7XG4gICAgICAgICAgICBpZiAocC5oZWFkLmxpc3RlbmVyID09IGxpc3RlbmVyKVxuICAgICAgICAgICAgICAgIHJldHVybiBwLmhlYWQ7XG4gICAgICAgICAgICBwID0gcC50YWlsO1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiBudWxsO1xuICAgIH07XG4gICAgU2xvdExpc3QucHJvdG90eXBlLnRvU3RyaW5nID0gZnVuY3Rpb24gKCkge1xuICAgICAgICB2YXIgYnVmZmVyID0gJyc7XG4gICAgICAgIHZhciBwID0gdGhpcztcbiAgICAgICAgd2hpbGUgKHAubm9uRW1wdHkpIHtcbiAgICAgICAgICAgIGJ1ZmZlciArPSBwLmhlYWQgKyBcIiAtPiBcIjtcbiAgICAgICAgICAgIHAgPSBwLnRhaWw7XG4gICAgICAgIH1cbiAgICAgICAgYnVmZmVyICs9IFwiTklMXCI7XG4gICAgICAgIHJldHVybiBcIltMaXN0IFwiICsgYnVmZmVyICsgXCJdXCI7XG4gICAgfTtcbiAgICAvKipcbiAgICAgKiBSZXByZXNlbnRzIGFuIGVtcHR5IGxpc3QuIFVzZWQgYXMgdGhlIGxpc3QgdGVybWluYXRvci5cbiAgICAgKi9cbiAgICBTbG90TGlzdC5OSUwgPSBuZXcgU2xvdExpc3QobnVsbCwgbnVsbCk7XG4gICAgcmV0dXJuIFNsb3RMaXN0O1xufSg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B8XG4gICAgICAgICAgICAoYnVmZmVyW2luZGV4KytdICYgMHgzRik7XG5cbiAgICB9IGVsc2UgaWYgKChjaHIgJiAweEYwKSA9PT0gMHhFMCkge1xuICAgICAgLy8gMyBieXRlc1xuICAgICAgY2hyID0gKGNociAmIDB4MEYpICAgICAgICAgICAgIDw8IDEyIHxcbiAgICAgICAgICAgIChidWZmZXJbaW5kZXgrK10gJiAweDNGKSA8PCA2ICB8XG4gICAgICAgICAgICAoYnVmZmVyW2luZGV4KytdICYgMHgzRik7XG5cbiAgICB9IGVsc2UgaWYgKChjaHIgJiAweEY4KSA9PT0gMHhGMCkge1xuICAgICAgLy8gNCBieXRlc1xuICAgICAgY2hyID0gKGNociAmIDB4MDcpICAgICAgICAgICAgIDw8IDE4IHxcbiAgICAgICAgICAgIChidWZmZXJbaW5kZXgrK10gJiAweDNGKSA8PCAxMiB8XG4gICAgICAgICAgICAoYnVmZmVyW2luZGV4KytdICYgMHgzRikgPDwgNiAgfFxuICAgICAgICAgICAgKGJ1ZmZlcltpbmRleCsrXSAmIDB4M0YpO1xuICAgIH1cblxuICAgIGlmIChjaHIgPj0gMHgwMTAwMDApIHtcbiAgICAgIC8vIEEgc3Vycm9nYXRlIHBhaXJcbiAgICAgIGNociAtPSAweDAxMDAwMDtcblxuICAgICAgc3RyaW5nICs9IFN0cmluZy5mcm9tQ2hhckNvZGUoKGNociA+Pj4gMTApICsgMHhEODAwLCAoY2hyICYgMHgzRkYpICsgMHhEQzAwKTtcbiAgICB9IGVsc2Uge1xuICAgICAgc3RyaW5nICs9IFN0cmluZy5mcm9tQ2hhckNvZGUoY2hyKTtcbiAgICB9XG4gIH1cblxuICByZXR1cm4gc3RyaW5nO1xufVxuXG4vKipcbiAqIEJ1ZmZlci5wcm90b3R5cGUuY29weSgpXG4gKlxuICogQHBhcmFtIHRhcmdldCB7QnVmZmVyfVxuICogQHBhcmFtIFt0YXJnZXRTdGFydF0ge051bWJlcn1cbiAqIEBwYXJhbSBbc3Rhcn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XBlLmxpc3RlbiA9IGZ1bmN0aW9uIChzZWdtZW50cywgY2FsbGJhY2spIHtcbiAgICAgICAgdmFyIF90aGlzID0gdGhpcztcbiAgICAgICAgdmFyIHJ1bGVzO1xuICAgICAgICBpZiAodHlwZW9mIChzZWdtZW50cykgPT09IFwiZnVuY3Rpb25cIikge1xuICAgICAgICAgICAgcnVsZXMgPSBbXTtcbiAgICAgICAgICAgIGNhbGxiYWNrID0gc2VnbWVudHM7XG4gICAgICAgIH1cbiAgICAgICAgZWxzZSB7XG4gICAgICAgICAgICBydWxlcyA9IHNlZ21lbnRzLnNwbGl0KFwiL1wiKTtcbiAgICAgICAgfVxuICAgICAgICB2YXIgbGlzdGVuZXIgPSB7XG4gICAgICAgICAgICBjYWxsYmFjazogY2FsbGJhY2ssXG4gICAgICAgICAgICByYXdSdWxlczogcnVsZXMsXG4gICAgICAgICAgICBydWxlczogcnVsZXMubWFwKGZ1bmN0aW9uIChzZWdtZW50KSB7XG4gICAgICAgICAgICAgICAgaWYgKHR5cGVvZiAoc2VnbWVudCkgPT09IFwic3RyaW5nXCIpIHtcbiAgICAgICAgICAgICAgICAgICAgLy8gcmVwbGFjZSBwbGFjZWhvbGRlciBtYXRjaGVyc1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gKHNlZ21lbnQuaW5kZXhPZihcIjpcIikgPT09IDApXG4gICAgICAgICAgICAgICAgICAgICAgICA/IF90aGlzLm1hdGNoZXJQbGFjZWhvbGRlcnNbc2VnbWVudF0gfHwgX3RoaXMubWF0Y2hlclBsYWNlaG9sZGVyc1tcIjoqXCJdXG4gICAgICAgICAgICAgICAgICAgICAgICA6IG5ldyBSZWdFeHAoXCJeXCIgKyBzZWdtZW50ICsgXCIkXCIpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHNlZ21lbnQ7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSlc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GVuZXJzW2pdO1xuICAgICAgICAgICAgICAgIHZhciBwYXRoVmFyaWFibGVzID0gdGhpcy5nZXRQYXRoVmFyaWFibGVzKHBhdGNoZXNbaV0sIGxpc3RlbmVyKTtcbiAgICAgICAgICAgICAgICBpZiAocGF0aFZhcmlhYmxlcykge1xuICAgICAgICAgICAgICAgICAgICBsaXN0ZW5lci5jYWxsYmFjayh7XG4gICAgICAgICAgICAgICAgICAgICAgICBwYXRoOiBwYXRoVmFyaWFibGVzLFxuICAgICAgICAgICAgICAgICAgICAgICAgcmF3UGF0aDogcGF0Y2hlc1tpXS5wYXRoLFxuICAgICAgICAgICAgICAgICAgICAgICAgb3BlcmF0aW9uOiBwYXRjaGVzW2ldLm9wZXJhdGlvbixcbiAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBwYXRjaGVzW2ldLnZhbHVlXG4gICAgICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgICAgICBtYXRjaGVkID0gdHJ1ZTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICAvLyBjaGVjayBmb3IgZmFsbGJhY2sgbGlzdGVuZXJcbiAgICAgICAgICAgIGlmICghbWF0Y2hlZCAmJiB0aGlzLmRlZmF1bHRMaXN0ZW5lcikge1xuICAgICAgICAgICAgICAgIHRoaXMuZGVmYXVsdExpc3RlbmVyLmNhbGxiYWNrKHBhdGNoZXNbaV0pO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfTtcbiAgICBEZWx0YUNvbnRhaW5lci5wcm90b3R5cGUuZ2V0UGF0aFZhcmlhYmxlcyA9IGZ1bmN0aW9uIChwYXRjaCwgbGlzdGVuZXIpIHtcbiAgICAgICAgLy8gc2tpcCBpZiBydWxlcyBjb3VudCBkaWZmZXIgZnJvbSBwYXRjaFxuICAgICAgICBpZiAocGF0Y2gucGF0aC5sZW5ndGggIT09IGxpc3RlbmVyLnJ1bGVzLmxlbmd0aCkge1xuICAgIC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yKTtcbiAgICB9XG4gICAgLyoqXG4gICAgICogQGluaGVyaXREb2NcbiAgICAgKi9cbiAgICBTbG90LnByb3RvdHlwZS5leGVjdXRlMCA9IGZ1bmN0aW9uICgpIHtcbiAgICAgICAgaWYgKCF0aGlzLl9lbmFibGVkKVxuICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICBpZiAodGhpcy5fb25jZSlcbiAgICAgICAgICAgIHRoaXMucmVtb3ZlKCk7XG4gICAgICAgIGlmICh0aGlzLl9wYXJhbXMgJiYgdGhpcy5fcGFyYW1zLmxlbmd0aCkge1xuICAgICAgICAgICAgdGhpcy5fbGlzdGVuZXIuYXBwbHkobnVsbCwgdGhpcy5fcGFyYW1zKTtcbiAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgfVxuICAgICAgICB0aGlzLl9saXN0ZW5lcigpO1xuICAgIH07XG4gICAgLyoqXG4gICAgICogQGluaGVyaXREb2NcbiAgICAgKi9cbiAgICBTbG90LnByb3RvdHlwZS5leGVjdXRlMSA9IGZ1bmN0aW9uICh2YWx1ZSkge1xuICAgICAgICBpZiAoIXRoaXMuX2VuYWJsZWQpXG4gICAgICAgICAgICByZXR1cm47XG4gICAgICAgIGlmICh0aGlzLl9vbmNlKVxuICAgICAgICAgICAgdGhpcy5yZW1vdmUoKTtcbiAgICAgICAgaWYgKHRoaXMuX3BhcmFtcyAmJiB0aGlzLl9wYXJhbXMubGVuZ3RoKSB7XG4gICAgICAgICAgICB0aGlzLl9saXN0ZW5lci5hcHBseShudWxsLCBbdmFsdWVdLmNvbmNhdCh0aGlzLl9wYXJhbXMpKTtcbiAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgfVxuICAgICAgICB0aGlzLl9saXN0ZW5lcih2YWx1ZSk7XG4gICAgfTtcbiAgICAvKipcbiAgICAgKiBAaW5oZXJpdERvY1xuICAgICAqL1xuICAgIFNsb3QucHJvdG90eXBlLmV4ZWN1dGUgPSBmdW5jdGlvbiAodmFsdWVPYmplY3RzKS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WZ5TGlzdGVuZXIodmFsdWUpO1xuICAgICAgICAgICAgdGhpcy5fbGlzdGVuZXIgPSB2YWx1ZTtcbiAgICAgICAgfSxcbiAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSxcbiAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlXG4gICAgfSk7XG4gICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KFNsb3QucHJvdG90eXBlLCBcIm9uY2VcIiwge1xuICAgICAgICAvKipcbiAgICAgICAgICogQGluaGVyaXREb2NcbiAgICAgICAgICovXG4gICAgICAgIGdldDogZnVuY3Rpb24gKCkge1xuICAgICAgICAgICAgcmV0dXJuIHRoaXMuX29uY2U7XG4gICAgICAgIH0sXG4gICAgICAgIGVudW1lcmFibGU6IHRydWUsXG4gICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZVxuICAgIH0pO1xuICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShTbG90LnByb3RvdHlwZSwgXCJwcmlvcml0eVwiLCB7XG4gICAgICAgIC8qKlxuICAgICAgICAgKiBAaW5oZXJpdERvY1xuICAgICAgICAgKi9cbiAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICByZXR1cm4gdGhpcy5fcHJpb3JpdHk7XG4gICAgICAgIH0sXG4gICAgICAgIGVudW1lcmFibGU6IHRydWUsXG4gICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZVxuICAgIH0pO1xuICAgIC8qKlxuICAgICAqIENyZWF0ZXMgYW5kIHJldHVybnMgdGhlIHN0cmluZyByZXByZXNlbnRhdGlvbiBvZiB0aGUgY3VycmVudCBvYmplY3QuXG4gICAgICpcbiAgICAgKiBAcmV0dXJuIFRoZSBzdHJpbmcgcmVwcmVzZW50YXRpb24gb2YgdGhlIGN1cnJlbnQgb2JqZWN0LlxuICAgICAqL1xuICAgIFNsb3QucHJvdG90eXBlLnRvU3RyaW5nID0gZnVuY3Rpb24gKCkge1xuICAgICAgICByZXR1cm4gXCJbU2xvdCBsaXN0ZW5lcjogXCIgKyB0aGlzLl9saXN0ZW5lciArIFwiLCBvbmNlOiBcIiArIHRoaXMuX29uY2VcbiAgICAgICAgICAgICsgXCIsIHByaW9yaXR5OiBcIiArIHRoaXMuX3ByaW9yaXR5ICsgXCIsIGVuYWJsZWQ6IFwiICsgdGhpcy5fZW5hYmxlZCArIFwiXVwiO1xuICAgIH07XG4gICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KFNsb3QucHJvdG90eXBlLCBcImVuYWJsZWRcIiwge1xuICAgICAgICAvKipcbiAgICAgICAgICogQGluaGVyaXREb2NcbiAgICAgICAgICovXG4gICAgICAgIGdldDogZnVuY3Rpb24gKCkge1xuICAgICAgICAgICAgcmV0dXJuIHRoaXMuX2VuYWJsZWQ7XG4gICAgICAgIH0sXG4gICAgICAgIHNldDogZnVuY3Rpb24gKHZhbHVlKSB7XG4gICAgICAgICAgICB0aGlzLl9lbmFibGVkID0gdmFsdWU7XG4gICAgICAgIH0sXG4gICAgICAgIGVudW1lcmFibGU6IHRydWUsXG4gICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZVxuICAgIH0pO1xuICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShTbG90LnByb3RvdHlwZSwgXCJwYXJhbXNcIiwge1xuICAgICAgICAvKipcbiAgICAgICAgICogQGluaGVyaXREb2NcbiAgICAgICAgICovXG4gICAgICAgIGdldDogZnVuY3Rpb24gKCkge1xuICAgICAgICAgICAgcmV0dXJuIHRoaXMuX3BhcmFtcztcbiAgICAgICAgfSxcbiAgICAgICAgc2V0OiBmdW5jdGlvbiAodmFsdWUpIHtcbiAgICAgICAgICAgIHRoaXMuX3BhcmFtcyA9IHZhbHVlO1xuICAgICAgICB9LFxuICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLFxuICAgICAgICBjb25maWd1cmFibGU6IHRydWVcbiAgICB9KTtcbiAgICAvKipcbiAgICAgKiBAaW5oZXJpdERvY1xuICAg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dC5cbiAgICAgICAgICovXG4gICAgICAgIGdldDogZnVuY3Rpb24gKCkge1xuICAgICAgICAgICAgaWYgKCF0aGlzLm5vbkVtcHR5KVxuICAgICAgICAgICAgICAgIHJldHVybiAwO1xuICAgICAgICAgICAgaWYgKHRoaXMudGFpbCA9PSBTbG90TGlzdC5OSUwpXG4gICAgICAgICAgICAgICAgcmV0dXJuIDE7XG4gICAgICAgICAgICAvLyBXZSBjb3VsZCBjYWNoZSB0aGUgbGVuZ3RoLCBidXQgaXQgd291bGQgbWFrZSBtZXRob2RzIGxpa2UgZmlsdGVyTm90IHVubmVjZXNzYXJpbHkgY29tcGxpY2F0ZWQuXG4gICAgICAgICAgICAvLyBJbnN0ZWFkIHdlIGFzc3VtZSB0aGF0IE8obikgaXMgb2theSBzaW5jZSB0aGUgbGVuZ3RoIHByb3BlcnR5IGlzIHVzZWQgaW4gcmFyZSBjYXNlcy5cbiAgICAgICAgICAgIC8vIFdlIGNvdWxkIGFsc28gY2FjaGUgdGhlIGxlbmd0aCBsYXp5LCBidXQgdGhhdCBpcyBhIHdhc3RlIG9mIGFub3RoZXIgOGIgcGVyIGxpc3Qgbm9kZSAoYXQgbGVhc3QpLlxuICAgICAgICAgICAgdmFyIHJlc3VsdCA9IDA7XG4gICAgICAgICAgICB2YXIgcCA9IHRoaXM7XG4gICAgICAgICAgICB3aGlsZSAocC5ub25FbXB0eSkge1xuICAgICAgICAgICAgICAgICsrcmVzdWx0O1xuICAgICAgICAgICAgICAgIHAgPSBwLnRhaWw7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICByZXR1cm4gcmVzdWx0O1xuICAgICAgICB9LFxuICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLFxuICAgICAgICBjb25maWd1cmFibGU6IHRydWVcbiAgICB9KTtcbiAgICAvKipcbiAgICAgKiBQcmVwZW5kcyBhIHNsb3QgdG8gdGhpcyBsaXN0LlxuICAgICAqIEBwYXJhbSAgICBzbG90IFRoZSBpdGVtIHRvIGJl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0eShHZW5lcmljRXZlbnQucHJvdG90eXBlLCBcInRhcmdldFwiLCB7XG4gICAgICAgIC8qKiBAaW5oZXJpdERvYyAqL1xuICAgICAgICBnZXQ6IGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgIHJldHVybiB0aGlzLl90YXJnZXQ7XG4gICAgICAgIH0sXG4gICAgICAgIHNldDogZnVuY3Rpb24gKHZhbHVlKSB7XG4gICAgICAgICAgICB0aGlzLl90YXJnZXQgPSB2YWx1ZTtcbiAgICAgICAgfSxcbiAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSxcbiAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlXG4gICAgfSk7XG4gICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KEdlbmVyaWNFdmVudC5wcm90b3R5cGUsIFwiY3VycmVudFRhcmdldFwiLCB7XG4gICAgICAgIC8qKiBAaW5oZXJpdERvYyAqL1xuICAgICAgICBnZXQ6IGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgIHJldHVybiB0aGlzLl9jdXJyZW50VGFyZ2V0O1xuICAgICAgICB9LFxuICAgICAgICBzZXQ6IGZ1bmN0aW9uICh2YWx1ZSkge1xuICAgICAgICAgICAgdGhpcy5fY3VycmVudFRhcmdldCA9IHZhbHVlO1xuICAgICAgICB9LFxuICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLFxuICAgICAgICBjb25maWd1cmFibGU6IHRydWVcbiAgICB9KTtcbiAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoR2VuZXJpY0V2ZW50LnByb3RvdHlwZSwgXCJidWJibGVzXCIsIHtcbiAgICAgICAgLyoqIEBpbmhlcml0RG9jICovXG4gICAgICAgIGdldDogZnVuY3Rpb24gKCkge1xuICAgICAgICAgICAgcmV0dXJuIHRoaXMuX2J1YmJsZXM7XG4gICAgICAgIH0sXG4gICAgICAgIHNldDogZnVuY3Rpb24gKHZhbHVlKSB7XG4gICAgICAgICAgICB0aGlzLl9idWJibGVzID0gdmF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SB7XG4gICAgICAgICAgICBydWxlcyA9IFtdO1xuICAgICAgICAgICAgY2FsbGJhY2sgPSBzZWdtZW50cztcbiAgICAgICAgfVxuICAgICAgICBlbHNlIHtcbiAgICAgICAgICAgIHJ1bGVzID0gc2VnbWVudHMuc3BsaXQoXCIvXCIpO1xuICAgICAgICB9XG4gICAgICAgIHZhciBsaXN0ZW5lciA9IHtcbiAgICAgICAgICAgIGNhbGxiYWNrOiBjYWxsYmFjayxcbiAgICAgICAgICAgIHJhd1J1bGVzOiBydWxlcyxcbiAgICAgICAgICAgIHJ1bGVzOiBydWxlcy5tYXAoZnVuY3Rpb24gKHNlZ21lbnQpIHtcbiAgICAgICAgICAgICAgICBpZiAodHlwZW9mIChzZWdtZW50KSA9PT0gXCJzdHJpbmdcIikge1xuICAgICAgICAgICAgICAgICAgICAvLyByZXBsYWNlIHBsYWNlaG9sZGVyIG1hdGNoZXJzXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiAoc2VnbWVudC5pbmRleE9mKFwiOlwiKSA9PT0gMClcbiAgICAgICAgICAgICAgICAgICAgICAgID8gX3RoaXMubWF0Y2hlclBsYWNlaG9sZGVyc1tzZWdtZW50XSB8fCBfdGhpcy5tYXRjaGVyUGxhY2Vob2xkZXJzW1wiOipcIl1cbiAgICAgICAgICAgICAgICAgICAgICAgIDogbmV3IFJlZ0V4cChcIl5cIiArIHNlZ21lbnQgKyBcIiRcIik7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gc2VnbWVudDtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9KVxuICAgICAgICB9O1xuICAgICAgICBpZiAocnVsZXMubGVuZ3RoID09PSAwKSB7XG4gICAgICAgICAgICB0aGlzLmRlZmF1bHRMaXN0ZW5lciA9IGxpc3RlbmVyO1xuICAgICAgICB9XG4gICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgdGhpcy5saXN0ZW5lcnMucHVzaChsaXN0ZW5lcik7XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuIGxpc3RlbmVyO1xuICAgIH07XG4gICAgRGVsdGFDb250YWluZXIucHJvdG90eXBlLnJlbW92ZUxpc3RlbmVyID0gZnVuY3Rpb24gKGxpc3RlbmVyKSB7XG4gICAgICAgIGZvciAodmFyIGkgPSB0aGlzLmxpc3RlbmVycy5sZW5ndGggLSAxOyBpID49IDA7IGktLSkge1xuICAgICAgICAgICAgaWYgKHRoaXMubGlzdGVuZXJzW2ldID09PSBsaXN0ZW5lcikge1xuICAgICAgICAgICAgICAgIHRoaXMubGlzdGVuZXJzLnNwbGljZShpLCAxKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH07XG4gICAgRGVsdGFDb250YWluZXIucHJvdG90eXBlLnJlbW92ZUFsbExpc3RlbmVycyA9IGZ1bmN0aW9uICgpIHtcbiAgICAgICAgdGhpcy5yZXNldCgpO1xuICAgIH07XG4gICAgRGVsdGFDb250YWluZXIucHJvdG90eXBlLmNoZWNrUGF0Y2hlcyA9IGZ1bmN0aW9uIChwYXRjaGVzKSB7XG4gICAgICAgIGZvciAodmFyIGkgPSBwYXRjaGVzLmxlbmd0aCAtIDE7IGkgPj0gMDsgaS0tKSB7XG4gICAgICAgICAgICB2YXIgbWF0Y2hlZCA9IGZhbHNlO1xuICAgICAgICAgICAgZm9yICh2YXIgaiA9IDAsIGxlbiA9IHRoaXMubGlzdGVuZXJzLmxlbmd0aDsgaiA8IGxlbjsgaisrKSB7XG4gICAgICAgICAgICAgICAgdmFyIGxpc3RlbmVyID0gdGhpcy5saXN0ZW5lcnNbal07XG4gICAgICAgICAgICAgICAgdmFyIHBhdGhWYXJpYWJsZXMgPSB0aGlzLmdldFBhdGhWYXJpYWJsZXMocGF0Y2hlc1tpXSwgbGlzdGVuZXIpO1xuICAgICAgICAgICAgICAgIGlmIChwYXRoVmFyaWFibGVzKSB7XG4gICAgICAgICAgICAgICAgICAgIGxpc3RlbmVyLmNhbGxiYWNrKHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHBhdGg6IHBhdGhWYXJpYWJsZXMsXG4gICAgICAgICAgICAgICAgICAgICAgICByYXdQYXRoOiBwYXRjaGVzW2ldLnBhdGgsXG4gICAgICAgICAgICAgICAgICAgICAgICBvcGVyYXRpb246IHBhdGNoZXNbaV0ub3BlcmF0aW9uLFxuICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHBhdGNoZXNbaV0udmFsdWVcbiAgICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgICAgIG1hdGNoZWQgPSB0cnVlO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIC8vIGNoZWNrIGZvciBmYWxsYmFjayBsaXN0ZW5lclxuICAgICAgICAgICAgaWYgKCFtYXRjaGVkICYmIHRoaXMuZGVmYXVsdExpc3RlbmVyKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5kZWZhdWx0TGlzdGVuZXIuY2FsbGJhY2socGF0Y2hlc1tpXSk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9O1xuICAgIERlbHRhQ29udGFpbmVyLnByb3RvdHlwZS5nZXRQYXRoVmFyaWFibGVzID0gZnVuY3Rpb24gKHBhdGNoLCBsaXN0ZW5lcikge1xuICAgICAgICAvLyBza2lwIGlmIHJ1bGVzIGNvdW50IGRpZmZlciBmcm9tIHBhdGNoXG4gICAgICAgIGlmIChwYXRjaC5wYXRoLmxlbmd0aCAhPT0gbGlzdGVuZXIucnVsZXMubGVuZ3RoKSB7XG4gICAgICAgICAgICByZXR1cm4gZmFsc2U7XG4gICAgICAgIH1cbiAgICAgICAgdmFyIHBhdGggPSB7fTtcbiAgICAgICAgZm9yICh2YXIgaSA9IDAsIGxlbiA9IGxpc3RlbmVyLnJ1bGVzLmxlbmd0aDsgaSA8IGxlbjsgaSsrKSB7XG4gICAgICAgICAgICB2YXIg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taXJyb3IpO1xuICAgIHZhciBjaGFuZ2VkID0gZmFsc2U7XG4gICAgdmFyIGRlbGV0ZWQgPSBmYWxzZTtcbiAgICBmb3IgKHZhciB0ID0gb2xkS2V5cy5sZW5ndGggLSAxOyB0ID49IDA7IHQtLSkge1xuICAgICAgICB2YXIga2V5ID0gb2xkS2V5c1t0XTtcbiAgICAgICAgdmFyIG9sZFZhbCA9IG1pcnJvcltrZXldO1xuICAgICAgICBpZiAob2JqLmhhc093blByb3BlcnR5KGtleSkgJiYgIShvYmpba2V5XSA9PT0gdW5kZWZpbmVkICYmIG9sZFZhbCAhPT0gdW5kZWZpbmVkICYmIEFycmF5LmlzQXJyYXkob2JqKSA9PT0gZmFsc2UpKSB7XG4gICAgICAgICAgICB2YXIgbmV3VmFsID0gb2JqW2tleV07XG4gICAgICAgICAgICBpZiAodHlwZW9mIG9sZFZhbCA9PSBcIm9iamVjdFwiICYmIG9sZFZhbCAhPSBudWxsICYmIHR5cGVvZiBuZXdWYWwgPT0gXCJvYmplY3RcIiAmJiBuZXdWYWwgIT0gbnVsbCkge1xuICAgICAgICAgICAgICAgIGdlbmVyYXRlKG9sZFZhbCwgbmV3VmFsLCBwYXRjaGVzLCBjb25jYXQocGF0aCwga2V5KSk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBlbHNlIHtcbiAgICAgICAgICAgICAgICBpZiAob2xkVmFsICE9PSBuZXdWYWwpIHtcbiAgICAgICAgICAgICAgICAgICAgY2hhbmdlZCA9IHRydWU7XG4gICAgICAgICAgICAgICAgICAgIHBhdGNoZXMucHVzaCh7IG9wZXJhdGlvbjogXCJyZXBsYWNlXCIsIHBhdGg6IGNvbmNhdChwYXRoLCBrZXkpLCB2YWx1ZTogbmV3VmFsIH0pO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICBlbHNlIHtcbiAgICAgICAgICAgIHBhdGNoZXMucHVzaCh7IG9wZXJhdGlvbjogXCJy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y8vLy9cbi8vIFdFQlBBQ0sgRk9PVEVSXG4vLyAuL25vZGVfbW9kdWxlcy9AZ2FtZXN0ZGlvL3dlYnNvY2tldC9saWIvYmFja29mZi5qc1xuLy8gbW9kdWxlIGlkID0gNjBcbi8vIG1vZHVsZSBjaHVua3MgPSAwIl0sInNvdXJjZVJvb3QiOiIifQ== \ No newline at end of file diff --git a/dist/index.html b/dist/index.html index b9b1787..77ddffa 100644 --- a/dist/index.html +++ b/dist/index.html @@ -49,6 +49,11 @@ console.log('joined!'); }) + room.onLeave.add(function() { + room.connection.reconnectEnabled = false; + console.log("LEFT ROOM", arguments); + }); + room.onUpdate.add(function(data) { console.log("chat update: ", data) }); diff --git a/package.json b/package.json index 2749814..670b5e9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "colyseus.js", - "version": "0.7.5", + "version": "0.7.6", "description": "Multiplayer Game Client for the Browser", "keywords": [ "multiplayer", @@ -29,7 +29,7 @@ }, "dependencies": { "@gamestdio/clock": "^1.1.0", - "@gamestdio/websocket": "^0.1.13", + "@gamestdio/websocket": "^0.2.2", "delta-listener": "^2.1.0", "fossil-delta": "^1.0.0", "msgpack-lite": "^0.1.20", diff --git a/src/Room.ts b/src/Room.ts index 72d78d3..55e3f91 100644 --- a/src/Room.ts +++ b/src/Room.ts @@ -42,7 +42,7 @@ export class Room extends DeltaContainer { connect (connection: Connection) { this.connection = connection; this.connection.onmessage = this.onMessageCallback.bind(this); - this.connection.onclose = (e) => this.onLeave.dispatch(); + this.connection.onclose = (e) => this.onLeave.dispatch(e); } protected onMessageCallback (event) { diff --git a/src/index.ts b/src/index.ts index 3ec9b9d..bcdfcb5 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,3 +1,4 @@ export { Client } from "./Client"; export { Protocol } from "./Protocol"; export { Room } from "./Room"; +export { DataChange } from "delta-listener";