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

@leancloud/client-engine

Package Overview
Dependencies
Maintainers
4
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@leancloud/client-engine - npm Package Compare versions

Comparing version 0.8.0 to 1.0.0

22

build/game-manager.d.ts

@@ -37,2 +37,12 @@ /// <reference types="node" />

}
interface IGameManagerConfig<T extends Game> {
gameConstructor: IGameConstructor<T>;
appId: string;
appKey: string;
playServer?: string;
/** 创建游戏的并发数 */
concurrency?: number;
/** 匹配成功后座位的保留时间,超过这个时间后该座位将被释放 */
reservationHoldTime?: number;
}
/**

@@ -42,15 +52,13 @@ * GameManager 负责游戏房间的分配

export declare class GameManager<T extends Game> extends EventEmitter {
protected gameClass: IGameConstructor<T>;
protected appId: string;
protected appKey: string;
protected get availableGames(): T[];
get load(): number;
open: boolean;
protected gameConstructor: IGameConstructor<T>;
protected appId: string;
protected appKey: string;
protected playServer: string | undefined;
protected games: Set<T>;
protected queue: PQueue;
protected reservationHoldTime: number;
constructor(gameClass: IGameConstructor<T>, appId: string, appKey: string, { concurrency, reservationHoldTime, }?: {
concurrency?: number | undefined;
reservationHoldTime?: number | undefined;
});
constructor({ gameConstructor, appId, appKey, playServer, concurrency, reservationHoldTime, }: IGameManagerConfig<T>);
getStatus(): Promise<{

@@ -57,0 +65,0 @@ availableGames: string[];

@@ -15,13 +15,10 @@ "use strict";

class GameManager extends events_1.EventEmitter {
constructor(gameClass, appId, appKey, {
// 创建游戏的并发数
concurrency = 1,
// 匹配成功后座位的保留时间,超过这个时间后该座位将被释放。
reservationHoldTime = 10000, } = {}) {
constructor({ gameConstructor, appId, appKey, playServer, concurrency = 1, reservationHoldTime = 10000, }) {
super();
this.gameClass = gameClass;
this.open = true;
this.games = new Set();
this.gameConstructor = gameConstructor;
this.appId = appId;
this.appKey = appKey;
this.open = true;
this.games = new Set();
this.playServer = playServer;
this.queue = new p_queue_1.default({

@@ -97,2 +94,3 @@ concurrency,

appKey: this.appKey,
playServer: this.playServer,
ssl: env !== "production" && env !== "staging",

@@ -129,9 +127,9 @@ userId: id,

async createEmptyGame(options = {}) {
const { expectedUserIds, seatCount = this.gameClass.defaultSeatCount, roomName, roomOptions, } = options;
const { gameClass, } = this;
if (gameClass.maxSeatCount && seatCount > gameClass.maxSeatCount) {
throw new Error(`seatCount too large. The maxSeatCount is ${gameClass.maxSeatCount}`);
const { expectedUserIds, seatCount = this.gameConstructor.defaultSeatCount, roomName, roomOptions, } = options;
const { gameConstructor, } = this;
if (gameConstructor.maxSeatCount && seatCount > gameConstructor.maxSeatCount) {
throw new Error(`seatCount too large. The maxSeatCount is ${gameConstructor.maxSeatCount}`);
}
if (gameClass.minSeatCount && seatCount < gameClass.minSeatCount) {
throw new Error(`seatCount too small. The minSeatCount is ${gameClass.minSeatCount}`);
if (gameConstructor.minSeatCount && seatCount < gameConstructor.minSeatCount) {
throw new Error(`seatCount too small. The minSeatCount is ${gameConstructor.minSeatCount}`);
}

@@ -154,3 +152,3 @@ const masterClient = this.createMasterClient();

});
return new gameClass(room, masterClient);
return new gameConstructor(room, masterClient);
}

@@ -157,0 +155,0 @@ remove(game) {

{
"name": "@leancloud/client-engine",
"version": "0.8.0",
"version": "1.0.0",
"description": "Node.js SDK for LeanCloud ClientEngine",

@@ -38,3 +38,3 @@ "main": "build/index.js",

"ioredis": "^4.14.1",
"lodash": "^4.17.15",
"lodash": "^4.17.20",
"lodash-decorators": "^6.0.1",

@@ -45,5 +45,8 @@ "nanoid": "^2.1.9",

"peerDependencies": {
"@leancloud/play": "^0.18.0-beta.10",
"@leancloud/play": "^1.0.0",
"rxjs": "^6.5.4"
}
},
"files": [
"build/"
]
}

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