@colyseus/redis-driver
Version:
<div align="center"> <a href="https://github.com/colyseus/colyseus"> <img src="media/logo.svg?raw=true" width="60%" height="300" /> </a> <br> <br> <a href="https://npmjs.com/package/colyseus"> <img src="https://img.shields.io/npm/dm/coly
49 lines (42 loc) • 1.19 kB
text/typescript
import { type IRoomCache, logger } from '@colyseus/core';
import { Redis, type Cluster } from 'ioredis';
export class RoomData implements IRoomCache {
public clients: number = 0;
public locked: boolean = false;
public private: boolean = false;
public maxClients: number = Infinity;
public metadata: any;
public name: string;
public publicAddress: string;
public processId: string;
public roomId: string;
public createdAt: Date;
public unlisted: boolean = false;
#client: Redis | Cluster;
constructor(
initialValues: any,
client: Redis | Cluster
) {
this.#client = client;
this.createdAt = (initialValues && initialValues.createdAt)
? new Date(initialValues.createdAt)
: new Date();
for (const field in initialValues) {
if (initialValues.hasOwnProperty(field)) {
this[field] = initialValues[field];
}
}
}
public toJSON() {
return {
clients: this.clients,
createdAt: this.createdAt,
maxClients: this.maxClients,
metadata: this.metadata,
name: this.name,
publicAddress: this.publicAddress,
processId: this.processId,
roomId: this.roomId,
};
}
}