colyseus.js
Advanced tools
Comparing version 0.7.0-alpha.4 to 0.7.0-alpha.5
@@ -15,2 +15,3 @@ import { Signal } from "signals.js"; | ||
}; | ||
protected hostname: string; | ||
constructor(url: string); | ||
@@ -17,0 +18,0 @@ join<T>(roomName: string, options?: any): Room<T>; |
@@ -5,3 +5,2 @@ "use strict"; | ||
var signals_js_1 = require("signals.js"); | ||
var cookie = require("./Cookie"); | ||
var Protocol_1 = require("./Protocol"); | ||
@@ -19,3 +18,5 @@ var Room_1 = require("./Room"); | ||
this.rooms = {}; | ||
this.connection = new Connection_1.Connection(url); | ||
this.id = localStorage.getItem('colyseusid') || ""; | ||
this.hostname = url; | ||
this.connection = new Connection_1.Connection(this.hostname + "/?colyseusid=" + this.id); | ||
this.connection.onmessage = this.onMessageCallback.bind(this); | ||
@@ -26,6 +27,3 @@ this.connection.onclose = function (e) { return _this.onClose.dispatch(); }; | ||
this.connection.onopen = function () { | ||
console.log("onopen!"); | ||
var colyseusid = cookie.getItem('colyseusid'); | ||
if (colyseusid) { | ||
_this.id = colyseusid; | ||
if (_this.id) { | ||
_this.onOpen.dispatch(); | ||
@@ -49,3 +47,3 @@ } | ||
if (code == Protocol_1.Protocol.USER_ID) { | ||
cookie.setItem('colyseusid', message[1]); | ||
localStorage.setItem('colyseusid', message[1]); | ||
this.id = message[1]; | ||
@@ -57,3 +55,3 @@ this.onOpen.dispatch(); | ||
room_1.id = message[1]; | ||
room_1.connect(new Connection_1.Connection(this.connection.url + "/" + this.room.id)); | ||
room_1.connect(new Connection_1.Connection(this.hostname + "/" + this.room.id + "?colyseusid=" + this.id)); | ||
room_1.onLeave.add(function () { return delete _this.rooms[room_1.id]; }); | ||
@@ -60,0 +58,0 @@ this.rooms[room_1.id] = room_1; |
import WebSocketClient from "websocket.js"; | ||
export declare class Connection extends WebSocketClient { | ||
private _enqueuedCalls; | ||
constructor(url: any); | ||
constructor(url: any, query?: any); | ||
onOpenCallback(event: any): void; | ||
send(data: any): void; | ||
} |
@@ -17,3 +17,4 @@ "use strict"; | ||
__extends(Connection, _super); | ||
function Connection(url) { | ||
function Connection(url, query) { | ||
if (query === void 0) { query = {}; } | ||
var _this = _super.call(this, url) || this; | ||
@@ -20,0 +21,0 @@ _this._enqueuedCalls = []; |
@@ -27,3 +27,3 @@ # Migration guide for colyseus.js | ||
```typescript | ||
room.listen("entities/:id/:attribute", "replace", (id, attribute, value) => { | ||
room.state.listen("entities/:id/:attribute", "replace", (id, attribute, value) => { | ||
console.log(id, attribute, value); | ||
@@ -30,0 +30,0 @@ }) |
{ | ||
"name": "colyseus.js", | ||
"version": "0.7.0-alpha.4", | ||
"version": "0.7.0-alpha.5", | ||
"description": "Multiplayer Game Client for the Browser", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
804567