chamesu
Version:
This package contains all packages of the chat application.
33 lines (26 loc) • 846 B
text/typescript
/*
* Copyright (c) 2022.
* Author Peter Placzek (tada5hi)
* For the full copyright and license information,
* view the LICENSE file that was distributed with this source code.
*/
import {Redis} from "ioredis";
import {RecordStatus} from "../../../../modules/socket/status";
let roomStatus: RecordStatus<string> | undefined;
export function useChatRoomStatus(redisDatabase?: Redis) : RecordStatus<string> {
if(typeof roomStatus !== 'undefined') {
return roomStatus;
}
if(typeof redisDatabase == 'undefined') {
throw new Error('No namespace name injected in room event handlder...');
}
roomStatus = new RecordStatus<string>(
redisDatabase,
{
redisPrefix: 'chat',
redisSuffix: 'roomUser',
recordType: 'user'
}
);
return roomStatus;
}