Skip to content

Commit

Permalink
fixes Electron support. closes #30
Browse files Browse the repository at this point in the history
  • Loading branch information
endel committed Jun 6, 2018
1 parent 6285912 commit 801a91e
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 9 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.6",
"version": "0.9.7",
"description": "Multiplayer Game Client for the Browser",
"keywords": [
"multiplayer",
Expand Down
2 changes: 1 addition & 1 deletion src/Client.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Signal } from '@gamestdio/signals';
import * as msgpack from 'notepack.io';
import * as msgpack from './msgpack';

import { Connection } from './Connection';
import { Protocol } from './Protocol';
Expand Down
2 changes: 1 addition & 1 deletion src/Connection.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import WebSocketClient from '@gamestdio/websocket';
import * as msgpack from 'notepack.io';
import * as msgpack from './msgpack';

import { Protocol } from './Protocol';

Expand Down
2 changes: 1 addition & 1 deletion src/Room.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Signal } from '@gamestdio/signals';

import { StateContainer } from '@gamestdio/state-listener';
import * as fossilDelta from 'fossil-delta';
import * as msgpack from 'notepack.io';
import * as msgpack from './msgpack';

import { Client } from './Client';
import { Connection } from './Connection';
Expand Down
2 changes: 2 additions & 0 deletions src/msgpack.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export const encode = require('notepack.io/browser/encode');
export const decode = require('notepack.io/browser/decode');
10 changes: 5 additions & 5 deletions test/room_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { assert } from "chai";
import { Room, DataChange } from "../src";

import * as fossilDelta from "fossil-delta";
import * as msgpack from "notepack.io";
import * as msgpack from "../src/msgpack";

describe("Room", function() {
let room: Room = null;
Expand Down Expand Up @@ -33,18 +33,18 @@ describe("Room", function() {
'two': { hp: 95, lvl: 2, position: {x: 0, y: 0} },
}
};
(<any>room).setState(msgpack.encode(state), 0, 0);
(<any>room).setState(new Uint8Array(msgpack.encode(state)), 0, 0);

// get previous state encoded
let previousState = msgpack.encode(state);
let previousState = new Uint8Array(msgpack.encode(state));

// change state and encode it
let nextState = msgpack.encode({
let nextState = new Uint8Array(msgpack.encode({
players: {
'one': { hp: 40, lvl: 1, position: {x: 0, y: 100} },
'two': { hp: 95, lvl: 2, position: {x: 0, y: 0} },
}
});
}));
let delta = fossilDelta.create(previousState, nextState);

let patchCount = 0;
Expand Down

0 comments on commit 801a91e

Please sign in to comment.