Skip to content

Commit

Permalink
fix tslint. bump v0.9.15
Browse files Browse the repository at this point in the history
  • Loading branch information
endel committed Oct 28, 2018
1 parent e380459 commit b2b3851
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 10 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "colyseus.js",
"version": "0.9.14",
"version": "0.9.15",
"description": "Multiplayer Game Client for the Browser",
"keywords": [
"multiplayer",
Expand Down
7 changes: 6 additions & 1 deletion src/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,12 @@ export class Client {
return new Room<T>(roomName, options);
}

protected createRoomRequest<T> (roomName: string, options: JoinOptions, reuseRoomInstance?: Room<T>, retryCount?: number) {
protected createRoomRequest<T>(
roomName: string,
options: JoinOptions,
reuseRoomInstance?: Room<T>,
retryCount?: number,
) {
options.requestId = ++this.requestId;

const room = reuseRoomInstance || this.createRoom<T>(roomName, options);
Expand Down
4 changes: 2 additions & 2 deletions src/Room.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export class Room<T= any> extends StateContainer<T & any> {
this.connection.send([ Protocol.ROOM_DATA, this.id, data ]);
}

public get hasJoined () {
public get hasJoined() {
return this.sessionId !== undefined;
}

Expand Down Expand Up @@ -133,7 +133,7 @@ export class Room<T= any> extends StateContainer<T & any> {

protected patch( binaryPatch ) {
// apply patch
this._previousState = Buffer.from(fossilDelta.apply( this._previousState, binaryPatch));
this._previousState = Buffer.from(fossilDelta.apply(this._previousState, binaryPatch));

// trigger state callbacks
this.set( msgpack.decode( this._previousState ) );
Expand Down
2 changes: 1 addition & 1 deletion src/Storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* loaded.
*/

function getStorage () {
function getStorage() {
return (typeof (cc) !== 'undefined' && cc.sys && cc.sys.localStorage)
? cc.sys.localStorage // compatibility with cocos creator
: window.localStorage; // regular browser environment
Expand Down
7 changes: 5 additions & 2 deletions src/msgpack.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
export const encode = require('notepack.io/browser/encode');
export const decode = require('notepack.io/browser/decode');
import * as msgpackDecode from 'notepack.io/browser/decode';
import * as msgpackEncode from 'notepack.io/browser/encode';

export const decode = msgpackDecode;
export const encode = msgpackEncode;
14 changes: 14 additions & 0 deletions test/client_test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import './util';
import { assert } from "chai";
import { Client } from "../src";

describe("Client", function () {

it("join", function () {
const client = new Client("ws://localhost:2546");
const room = client.join("chat");
assert.equal(room.name, "chat")
assert.deepEqual(room.state, {})
});

});
9 changes: 6 additions & 3 deletions test/util.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import * as localStorage from "node-localstorage";
import { LocalStorage } from "node-localstorage";

(<any>global).WebSocket = {};
(<any>global).window = { localStorage: localStorage };
// mock WebSocket
(<any>global).WebSocket = class WebSocket { send() {} };

// mock localStorage
(<any>global).window = { localStorage: new LocalStorage('./tests') };

0 comments on commit b2b3851

Please sign in to comment.