New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

colyseus.js

Package Overview
Dependencies
Maintainers
1
Versions
272
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.16.0-preview.14 to 0.16.0-preview.15

lib/transport/H3Transport.d.ts

2

build/cjs/3rd_party/discord.js

@@ -1,2 +0,2 @@

// colyseus.js@0.16.0-preview.14
// colyseus.js@0.16.0-preview.15
'use strict';

@@ -3,0 +3,0 @@

@@ -1,2 +0,2 @@

// colyseus.js@0.16.0-preview.14
// colyseus.js@0.16.0-preview.15
'use strict';

@@ -3,0 +3,0 @@

@@ -1,2 +0,2 @@

// colyseus.js@0.16.0-preview.14
// colyseus.js@0.16.0-preview.15
'use strict';

@@ -178,3 +178,3 @@

targetRoom = reuseRoomInstance || room;
room.connect(this.buildEndpoint(response.room, options), response.devMode && (function () { return tslib.__awaiter(_this, void 0, void 0, function () {
room.connect(this.buildEndpoint(response.room, options, response.protocol), response.devMode && (function () { return tslib.__awaiter(_this, void 0, void 0, function () {
var retryCount, retryMaxRetries, retryReconnection;

@@ -216,3 +216,3 @@ var _this = this;

});
}); }), targetRoom);
}); }), targetRoom, response);
return [2 /*return*/, new Promise(function (resolve, reject) {

@@ -262,4 +262,5 @@ var onError = function (code, message) { return reject(new ServerError.ServerError(code, message)); };

};
Client.prototype.buildEndpoint = function (room, options) {
Client.prototype.buildEndpoint = function (room, options, protocol) {
if (options === void 0) { options = {}; }
if (protocol === void 0) { protocol = "ws"; }
var params = [];

@@ -273,5 +274,8 @@ // append provided options

}
if (protocol === "h3") {
protocol = "http";
}
var endpoint = (this.settings.secure)
? "wss://"
: "ws://";
? "".concat(protocol, "s://")
: "".concat(protocol, "://");
if (room.publicAddress) {

@@ -278,0 +282,0 @@ endpoint += "".concat(room.publicAddress);

@@ -1,2 +0,2 @@

// colyseus.js@0.16.0-preview.14
// colyseus.js@0.16.0-preview.15
'use strict';

@@ -6,14 +6,25 @@

var H3Transport = require('./transport/H3Transport.js');
var WebSocketTransport = require('./transport/WebSocketTransport.js');
var Connection = /** @class */ (function () {
function Connection() {
function Connection(protocol) {
this.events = {};
this.transport = new WebSocketTransport.WebSocketTransport(this.events);
switch (protocol) {
case "h3":
this.transport = new H3Transport.H3TransportTransport(this.events);
break;
default:
this.transport = new WebSocketTransport.WebSocketTransport(this.events);
break;
}
}
Connection.prototype.connect = function (url, options) {
this.transport.connect.call(this.transport, url, options);
};
Connection.prototype.send = function (data) {
this.transport.send(data);
};
Connection.prototype.connect = function (url) {
this.transport.connect(url);
Connection.prototype.sendUnreliable = function (data) {
this.transport.sendUnreliable(data);
};

@@ -20,0 +31,0 @@ Connection.prototype.close = function (code, reason) {

@@ -1,2 +0,2 @@

// colyseus.js@0.16.0-preview.14
// colyseus.js@0.16.0-preview.15
'use strict';

@@ -3,0 +3,0 @@

@@ -1,2 +0,2 @@

// colyseus.js@0.16.0-preview.14
// colyseus.js@0.16.0-preview.15
'use strict';

@@ -3,0 +3,0 @@

@@ -1,2 +0,2 @@

// colyseus.js@0.16.0-preview.14
// colyseus.js@0.16.0-preview.15
'use strict';

@@ -3,0 +3,0 @@

@@ -1,2 +0,2 @@

// colyseus.js@0.16.0-preview.14
// colyseus.js@0.16.0-preview.15
'use strict';

@@ -3,0 +3,0 @@

@@ -1,2 +0,2 @@

// colyseus.js@0.16.0-preview.14
// colyseus.js@0.16.0-preview.15
'use strict';

@@ -3,0 +3,0 @@

@@ -1,2 +0,2 @@

// colyseus.js@0.16.0-preview.14
// colyseus.js@0.16.0-preview.15
'use strict';

@@ -3,0 +3,0 @@

@@ -1,2 +0,2 @@

// colyseus.js@0.16.0-preview.14
// colyseus.js@0.16.0-preview.15
'use strict';

@@ -3,0 +3,0 @@

@@ -1,2 +0,2 @@

// colyseus.js@0.16.0-preview.14
// colyseus.js@0.16.0-preview.15
'use strict';

@@ -39,6 +39,6 @@

}
Room.prototype.connect = function (endpoint, devModeCloseCallback, room // when reconnecting on devMode, re-use previous room intance for handling events.
) {
Room.prototype.connect = function (endpoint, devModeCloseCallback, room, // when reconnecting on devMode, re-use previous room intance for handling events.
options) {
if (room === void 0) { room = this; }
var connection = new Connection.Connection();
var connection = new Connection.Connection(options.protocol);
room.connection = connection;

@@ -66,3 +66,10 @@ connection.events.onmessage = Room.prototype.onMessageCallback.bind(room);

};
connection.connect(endpoint);
// FIXME: refactor this.
if (options.protocol === "h3") {
var url = new URL(endpoint);
connection.connect(url.origin, options);
}
else {
connection.connect(endpoint);
}
};

@@ -107,2 +114,18 @@ Room.prototype.leave = function (consented) {

};
Room.prototype.sendUnreliable = function (type, message) {
var it = { offset: 1 };
this.packr.buffer[0] = Protocol.Protocol.ROOM_DATA;
if (typeof (type) === "string") {
schema.encode.string(this.packr.buffer, type, it);
}
else {
schema.encode.number(this.packr.buffer, type, it);
}
// force packr to use beginning of the buffer
this.packr.position = 0;
var data = (message !== undefined)
? this.packr.pack(message, 2048 + it.offset) // 2048 = RESERVE_START_SPACE
: this.packr.buffer.subarray(0, it.offset);
this.connection.sendUnreliable(data);
};
Room.prototype.sendBytes = function (type, bytes) {

@@ -109,0 +132,0 @@ var it = { offset: 1 };

@@ -1,2 +0,2 @@

// colyseus.js@0.16.0-preview.14
// colyseus.js@0.16.0-preview.15
'use strict';

@@ -3,0 +3,0 @@

@@ -1,2 +0,2 @@

// colyseus.js@0.16.0-preview.14
// colyseus.js@0.16.0-preview.15
'use strict';

@@ -3,0 +3,0 @@

@@ -1,2 +0,2 @@

// colyseus.js@0.16.0-preview.14
// colyseus.js@0.16.0-preview.15
'use strict';

@@ -3,0 +3,0 @@

@@ -1,2 +0,2 @@

// colyseus.js@0.16.0-preview.14
// colyseus.js@0.16.0-preview.15
'use strict';

@@ -3,0 +3,0 @@

@@ -1,2 +0,2 @@

// colyseus.js@0.15.15
// colyseus.js@0.16.0-preview.15
'use strict';

@@ -144,7 +144,8 @@

H3TransportTransport.prototype.sendSeatReservation = function (roomId, sessionId, reconnectionToken) {
var it = { offset: 0 };
var bytes = [];
schema.encode.string(bytes, roomId);
schema.encode.string(bytes, sessionId);
schema.encode.string(bytes, roomId, it);
schema.encode.string(bytes, sessionId, it);
if (reconnectionToken) {
schema.encode.string(bytes, reconnectionToken);
schema.encode.string(bytes, reconnectionToken, it);
}

@@ -151,0 +152,0 @@ this.writer.write(new Uint8Array(bytes).buffer);

@@ -1,2 +0,2 @@

// colyseus.js@0.16.0-preview.14
// colyseus.js@0.16.0-preview.15
'use strict';

@@ -20,2 +20,5 @@

};
WebSocketTransport.prototype.sendUnreliable = function (data) {
throw new Error("WebSocket does not support unreliable messages");
};
WebSocketTransport.prototype.connect = function (url) {

@@ -22,0 +25,0 @@ this.ws = new WebSocket(url, this.protocols);

@@ -39,5 +39,5 @@ import { Room, RoomAvailable } from './Room';

protected createRoom<T>(roomName: string, rootSchema?: SchemaConstructor<T>): Room<T>;
protected buildEndpoint(room: any, options?: any): string;
protected buildEndpoint(room: any, options?: any, protocol?: string): string;
protected getHttpEndpoint(segments?: string): string;
protected getEndpointPort(): string;
}

@@ -140,3 +140,3 @@ "use strict";

const targetRoom = reuseRoomInstance || room;
room.connect(this.buildEndpoint(response.room, options), response.devMode && (() => __awaiter(this, void 0, void 0, function* () {
room.connect(this.buildEndpoint(response.room, options, response.protocol), response.devMode && (() => __awaiter(this, void 0, void 0, function* () {
console.info(`[Colyseus devMode]: ${String.fromCodePoint(0x1F504)} Re-establishing connection with room id '${room.roomId}'...`); // 🔄

@@ -162,3 +162,3 @@ let retryCount = 0;

setTimeout(retryReconnection, 2000);
})), targetRoom);
})), targetRoom, response);
return new Promise((resolve, reject) => {

@@ -198,3 +198,3 @@ const onError = (code, message) => reject(new ServerError_1.ServerError(code, message));

}
buildEndpoint(room, options = {}) {
buildEndpoint(room, options = {}, protocol = "ws") {
const params = [];

@@ -208,5 +208,8 @@ // append provided options

}
if (protocol === "h3") {
protocol = "http";
}
let endpoint = (this.settings.secure)
? "wss://"
: "ws://";
? `${protocol}s://`
: `${protocol}://`;
if (room.publicAddress) {

@@ -213,0 +216,0 @@ endpoint += `${room.publicAddress}`;

@@ -6,7 +6,8 @@ /// <reference types="node" />

events: ITransportEventMap;
constructor();
constructor(protocol?: string);
connect(url: string, options?: any): void;
send(data: Buffer | Uint8Array): void;
connect(url: string): void;
sendUnreliable(data: Buffer | Uint8Array): void;
close(code?: number, reason?: string): void;
get isOpen(): boolean;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Connection = void 0;
const H3Transport_1 = require("./transport/H3Transport");
const WebSocketTransport_1 = require("./transport/WebSocketTransport");
class Connection {
constructor() {
constructor(protocol) {
this.events = {};
this.transport = new WebSocketTransport_1.WebSocketTransport(this.events);
switch (protocol) {
case "h3":
this.transport = new H3Transport_1.H3TransportTransport(this.events);
break;
default:
this.transport = new WebSocketTransport_1.WebSocketTransport(this.events);
break;
}
}
connect(url, options) {
this.transport.connect.call(this.transport, url, options);
}
send(data) {
this.transport.send(data);
}
connect(url) {
this.transport.connect(url);
sendUnreliable(data) {
this.transport.sendUnreliable(data);
}

@@ -16,0 +27,0 @@ close(code, reason) {

@@ -8,3 +8,3 @@ "use strict";

CloseCode[CloseCode["DEVMODE_RESTART"] = 4010] = "DEVMODE_RESTART";
})(CloseCode = exports.CloseCode || (exports.CloseCode = {}));
})(CloseCode || (exports.CloseCode = CloseCode = {}));
class ServerError extends Error {

@@ -11,0 +11,0 @@ constructor(code, message) {

@@ -7,2 +7,3 @@ import { RoomAvailable } from "./Room";

devMode?: boolean;
protocol?: string;
}

@@ -9,0 +10,0 @@ export declare enum Protocol {

@@ -17,3 +17,3 @@ "use strict";

Protocol[Protocol["ROOM_DATA_BYTES"] = 17] = "ROOM_DATA_BYTES";
})(Protocol = exports.Protocol || (exports.Protocol = {}));
})(Protocol || (exports.Protocol = Protocol = {}));
var ErrorCode;

@@ -28,3 +28,3 @@ (function (ErrorCode) {

ErrorCode[ErrorCode["APPLICATION_ERROR"] = 4216] = "APPLICATION_ERROR";
})(ErrorCode = exports.ErrorCode || (exports.ErrorCode = {}));
})(ErrorCode || (exports.ErrorCode = ErrorCode = {}));
//# sourceMappingURL=Protocol.js.map

@@ -57,3 +57,4 @@ import { Connection } from './Connection';

constructor(name: string, rootSchema?: SchemaConstructor<State>);
connect(endpoint: string, devModeCloseCallback?: () => void, room?: Room): void;
connect(endpoint: string, devModeCloseCallback?: () => void, room?: Room, // when reconnecting on devMode, re-use previous room intance for handling events.
options?: any): void;
leave(consented?: boolean): Promise<number>;

@@ -63,2 +64,3 @@ onMessage<T = any>(type: "*", callback: (type: string | number, message: T) => void): any;

send<T = any>(type: string | number, message?: T): void;
sendUnreliable(type: string | number, message?: Uint8Array): void;
sendBytes(type: string | number, bytes: Uint8Array): void;

@@ -65,0 +67,0 @@ get state(): State;

@@ -15,5 +15,2 @@ "use strict";

const msgpackr_1 = require("@colyseus/msgpackr");
const ByteArrayAllocate = (typeof Buffer !== 'undefined')
? function (length) { return Buffer.allocUnsafeSlow(length); }
: Uint8Array;
class Room {

@@ -41,5 +38,5 @@ constructor(name, rootSchema) {

}
connect(endpoint, devModeCloseCallback, room = this // when reconnecting on devMode, re-use previous room intance for handling events.
) {
const connection = new Connection_1.Connection();
connect(endpoint, devModeCloseCallback, room = this, // when reconnecting on devMode, re-use previous room intance for handling events.
options) {
const connection = new Connection_1.Connection(options.protocol);
room.connection = connection;

@@ -67,3 +64,10 @@ connection.events.onmessage = Room.prototype.onMessageCallback.bind(room);

};
connection.connect(endpoint);
// FIXME: refactor this.
if (options.protocol === "h3") {
const url = new URL(endpoint);
connection.connect(url.origin, options);
}
else {
connection.connect(endpoint);
}
}

@@ -106,2 +110,18 @@ leave(consented = true) {

}
sendUnreliable(type, message) {
const it = { offset: 1 };
this.packr.buffer[0] = Protocol_1.Protocol.ROOM_DATA;
if (typeof (type) === "string") {
schema_1.encode.string(this.packr.buffer, type, it);
}
else {
schema_1.encode.number(this.packr.buffer, type, it);
}
// force packr to use beginning of the buffer
this.packr.position = 0;
const data = (message !== undefined)
? this.packr.pack(message, 2048 + it.offset) // 2048 = RESERVE_START_SPACE
: this.packr.buffer.subarray(0, it.offset);
this.connection.sendUnreliable(data);
}
sendBytes(type, bytes) {

@@ -108,0 +128,0 @@ const it = { offset: 1 };

@@ -14,4 +14,5 @@ /// <reference types="node" />

send(data: Buffer | Uint8Array): void;
connect(url: string): void;
sendUnreliable(data: Buffer | Uint8Array): void;
connect(url: string, options: any): void;
close(code?: number, reason?: string): void;
}

@@ -10,2 +10,3 @@ /// <reference types="node" />

send(data: Buffer | Uint8Array): void;
sendUnreliable(data: ArrayBuffer | Array<number>): void;
connect(url: string): void;

@@ -12,0 +13,0 @@ close(code?: number, reason?: string): void;

@@ -16,2 +16,5 @@ "use strict";

}
sendUnreliable(data) {
throw new Error("WebSocket does not support unreliable messages");
}
connect(url) {

@@ -18,0 +21,0 @@ this.ws = new WebSocket(url, this.protocols);

{
"name": "colyseus.js",
"version": "0.16.0-preview.14",
"version": "0.16.0-preview.15",
"description": "Colyseus Multiplayer SDK for JavaScript/TypeScript",

@@ -88,4 +88,4 @@ "author": "Endel Dreyer",

"tslint": "^5.9.1",
"typescript": "^4.3.5"
"typescript": "^5.3.3"
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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