Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

colyseus.js

Package Overview
Dependencies
Maintainers
1
Versions
261
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

colyseus.js - npm Package Compare versions

Comparing version 0.7.0-alpha.1 to 0.7.0-alpha.2

MIGRATING.md

24

lib/Cookie.js
"use strict";
/*\
|*|
|*| :: cookies.js :: (from: https://developer.mozilla.org/en-US/docs/Web/API/Document/cookie/Simple_document.cookie_framework)
|*|
|*| A complete cookies reader/writer framework with full unicode support.
|*|
|*| Revision #1 - September 4, 2014
|*|
|*| https://developer.mozilla.org/en-US/docs/Web/API/document.cookie
|*| https://developer.mozilla.org/User:fusionchess
|*| https://github.com/madmurphy/cookies.js
|*|
|*| This framework is released under the GNU Public License, version 3 or later.
|*| http://www.gnu.org/licenses/gpl-3.0-standalone.html
|*|
|*| Syntaxes:
|*|
|*| * docCookies.setItem(name, value[, end[, path[, domain[, secure]]]])
|*| * docCookies.getItem(name)
|*| * docCookies.removeItem(name[, path[, domain]])
|*| * docCookies.hasItem(name)
|*| * docCookies.keys()
|*|
\*/
Object.defineProperty(exports, "__esModule", { value: true });

@@ -3,0 +27,0 @@ function getItem(sKey) {

5

lib/Room.d.ts

@@ -5,7 +5,6 @@ import { Signal } from "signals.js";

import { Connection } from "./Connection";
export declare class Room<T = any> {
export declare class Room<T = any> extends DeltaContainer<T & any> {
id: number;
name: string;
sessionId: string;
state: DeltaContainer<T & any>;
clock: Clock;

@@ -29,3 +28,3 @@ remoteClock: Clock;

send(data: any): void;
removeAllListeners: () => void;
removeAllListeners(): void;
}

61

lib/Room.js
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });

@@ -9,25 +19,18 @@ var signals_js_1 = require("signals.js");

var Protocol_1 = require("./Protocol");
var Room = (function () {
var Room = (function (_super) {
__extends(Room, _super);
function Room(name) {
var _this = this;
this.state = new delta_listener_1.DeltaContainer({});
this.clock = new Clock();
this.remoteClock = new Clock();
var _this = _super.call(this, {}) || this;
_this.clock = new Clock(); // experimental
_this.remoteClock = new Clock(); // experimental
// Public signals
this.onJoin = new signals_js_1.Signal();
this.onUpdate = new signals_js_1.Signal();
this.onData = new signals_js_1.Signal();
this.onError = new signals_js_1.Signal();
this.onLeave = new signals_js_1.Signal();
this.removeAllListeners = function () {
_this.onJoin.removeAll();
_this.onUpdate.removeAll();
_this.onData.removeAll();
_this.onError.removeAll();
_this.onLeave.removeAll();
_this.state.removeAllListeners();
};
this.id = null;
this.name = name;
this.onLeave.add(this.removeAllListeners);
_this.onJoin = new signals_js_1.Signal();
_this.onUpdate = new signals_js_1.Signal();
_this.onData = new signals_js_1.Signal();
_this.onError = new signals_js_1.Signal();
_this.onLeave = new signals_js_1.Signal();
_this.id = null;
_this.name = name;
_this.onLeave.add(function () { return _this.removeAllListeners(); });
return _this;
}

@@ -67,3 +70,3 @@ Room.prototype.connect = function (connection) {

Room.prototype.setState = function (state, remoteCurrentTime, remoteElapsedTime) {
this.state.set(state);
this.set(state);
this._previousState = msgpack.encode(state);

@@ -91,4 +94,4 @@ // set remote clock properties

// trigger state callbacks
this.state.set(msgpack.decode(this._previousState));
this.onUpdate.dispatch(this.state.data);
this.set(msgpack.decode(this._previousState));
this.onUpdate.dispatch(this.data);
};

@@ -103,4 +106,12 @@ Room.prototype.leave = function () {

};
Room.prototype.removeAllListeners = function () {
_super.prototype.removeAllListeners.call(this);
this.onJoin.removeAll();
this.onUpdate.removeAll();
this.onData.removeAll();
this.onError.removeAll();
this.onLeave.removeAll();
};
return Room;
}());
}(delta_listener_1.DeltaContainer));
exports.Room = Room;
{
"name": "colyseus.js",
"version": "0.7.0-alpha.1",
"version": "0.7.0-alpha.2",
"description": "Multiplayer Game Client for the Browser",

@@ -5,0 +5,0 @@ "keywords": [

@@ -43,3 +43,3 @@ # ![colyseus.js](https://github.com/gamestdio/colyseus/blob/master/media/header.png?raw=true)

```ts
room.state.listen("entities/:id", "add", (entityId: string, value: any) => {
room.listen("entities/:id", "add", (entityId: string, value: any) => {
console.log(`new entity ${entityId}`, value);

@@ -52,3 +52,3 @@ });

```ts
room.state.listen("entities/:id/:attribute", "replace", (entityId: string, attribute: string, value: any) => {
room.listen("entities/:id/:attribute", "replace", (entityId: string, attribute: string, value: any) => {
console.log(`entity ${entityId} changed attribute ${attribute} to ${value}`);

@@ -61,3 +61,3 @@ });

```ts
room.state.listen("entities/:id", "remove", (entityId: string) => {
room.listen("entities/:id", "remove", (entityId: string) => {
console.log(`entity ${entityId} has been removed`);

@@ -64,0 +64,0 @@ });

@@ -0,1 +1,26 @@

/*\
|*|
|*| :: cookies.js :: (from: https://developer.mozilla.org/en-US/docs/Web/API/Document/cookie/Simple_document.cookie_framework)
|*|
|*| A complete cookies reader/writer framework with full unicode support.
|*|
|*| Revision #1 - September 4, 2014
|*|
|*| https://developer.mozilla.org/en-US/docs/Web/API/document.cookie
|*| https://developer.mozilla.org/User:fusionchess
|*| https://github.com/madmurphy/cookies.js
|*|
|*| This framework is released under the GNU Public License, version 3 or later.
|*| http://www.gnu.org/licenses/gpl-3.0-standalone.html
|*|
|*| Syntaxes:
|*|
|*| * docCookies.setItem(name, value[, end[, path[, domain[, secure]]]])
|*| * docCookies.getItem(name)
|*| * docCookies.removeItem(name[, path[, domain]])
|*| * docCookies.hasItem(name)
|*| * docCookies.keys()
|*|
\*/
export function getItem (sKey) {

@@ -2,0 +27,0 @@ if (!sKey) { return null; }

@@ -12,3 +12,3 @@ import { Signal } from "signals.js";

export class Room<T=any> {
export class Room<T=any> extends DeltaContainer<T & any> {
public id: number;

@@ -18,7 +18,5 @@ public name: string;

public state: DeltaContainer<T & any> = new DeltaContainer<T & any>({});
public clock: Clock = new Clock(); // experimental
public remoteClock: Clock = new Clock(); // experimental
public clock: Clock = new Clock();
public remoteClock: Clock = new Clock();
// Public signals

@@ -31,3 +29,3 @@ public onJoin: Signal = new Signal();

public ping: number;
public ping: number; // experimental
private lastPatchTime: number;

@@ -39,5 +37,8 @@

constructor (name: string) {
super({});
this.id = null;
this.name = name;
this.onLeave.add( this.removeAllListeners );
this.onLeave.add( () => this.removeAllListeners() );
}

@@ -81,3 +82,3 @@

setState ( state: T, remoteCurrentTime?: number, remoteElapsedTime?: number ): void {
this.state.set(state);
this.set(state);
this._previousState = msgpack.encode( state )

@@ -114,5 +115,5 @@

// trigger state callbacks
this.state.set( msgpack.decode( this._previousState ) );
this.set( msgpack.decode( this._previousState ) );
this.onUpdate.dispatch(this.state.data);
this.onUpdate.dispatch(this.data);
}

@@ -130,3 +131,4 @@

public removeAllListeners = (): void => {
public removeAllListeners () {
super.removeAllListeners();
this.onJoin.removeAll();

@@ -137,5 +139,4 @@ this.onUpdate.removeAll();

this.onLeave.removeAll();
this.state.removeAllListeners();
}
}

@@ -11,3 +11,3 @@ const assert = require('chai').assert;

beforeEach(function() {
room = new Room(null, "chat");
room = new Room("chat");
});

@@ -17,3 +17,3 @@

assert.equal(room.name, "chat")
assert.deepEqual(room.state.data, {})
assert.deepEqual(room.data, {})
});

@@ -51,3 +51,3 @@

let patchCount = 0;
room.state.listen("players/:id/:attribute", "replace", (id, attribute, value) => {
room.listen("players/:id/:attribute", "replace", (id, attribute, value) => {
patchCount++

@@ -59,3 +59,3 @@ assert.equal(id, "one");

room.state.listen("players/:id/position/:axis", "replace", (id, axis, value) => {
room.listen("players/:id/position/:axis", "replace", (id, axis, value) => {
patchCount++

@@ -62,0 +62,0 @@ assert.equal(id, "one");

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc