colyseus.js
Advanced tools
Comparing version 0.7.1 to 0.7.2-rc1
@@ -17,2 +17,3 @@ import { Signal } from "signals.js"; | ||
constructor(url: string); | ||
protected createConnection(colyseusid: string): void; | ||
join<T>(roomName: string, options?: any): Room<T>; | ||
@@ -19,0 +20,0 @@ /** |
@@ -8,2 +8,6 @@ "use strict"; | ||
var Connection_1 = require("./Connection"); | ||
// use AsyncStorage on react-native environment. | ||
if (typeof (localStorage) === "undefined") { | ||
localStorage = global.AsyncStorage; | ||
} | ||
var Client = /** @class */ (function () { | ||
@@ -18,4 +22,16 @@ function Client(url) { | ||
this.rooms = {}; | ||
this.id = localStorage.getItem('colyseusid') || ""; | ||
this.hostname = url; | ||
var colyseusid = localStorage.getItem('colyseusid') || ""; | ||
if (!(colyseusid instanceof Promise)) { | ||
// browser has synchronous return | ||
this.createConnection(colyseusid); | ||
} | ||
else { | ||
// react-native is asynchronous | ||
colyseusid.then(function (id) { return _this.createConnection(id); }); | ||
} | ||
} | ||
Client.prototype.createConnection = function (colyseusid) { | ||
var _this = this; | ||
this.id = colyseusid; | ||
this.connection = new Connection_1.Connection(this.hostname + "/?colyseusid=" + this.id); | ||
@@ -31,3 +47,3 @@ this.connection.onmessage = this.onMessageCallback.bind(this); | ||
}; | ||
} | ||
}; | ||
Client.prototype.join = function (roomName, options) { | ||
@@ -34,0 +50,0 @@ if (options === void 0) { options = {}; } |
{ | ||
"name": "colyseus.js", | ||
"version": "0.7.1", | ||
"version": "0.7.2-rc1", | ||
"description": "Multiplayer Game Client for the Browser", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -5,3 +5,3 @@ { | ||
"module": "commonjs", | ||
"lib": ["dom", "es5"], | ||
"lib": ["dom", "es6"], | ||
"allowSyntheticDefaultImports": true, | ||
@@ -8,0 +8,0 @@ "noImplicitAny": false, |
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
596957
531