General Actions to handlers Refacto
This commit is contained in:
+10
-4
@@ -9,9 +9,11 @@ export class RedisConnexion {
|
||||
this.redisConfig = this.config
|
||||
this.meshName = options.meshName
|
||||
this.meshModule = options.meshModule ?? null
|
||||
this.senderId = options.senderId ?? null
|
||||
this.actionsReply = options.actionsReply ?? null
|
||||
|
||||
if(this.meshModule?.meshActions) Object.assign(this, this.meshModule.meshActions)
|
||||
this.afterLoginMethods = this.meshModule?.afterLoginMethods ?? []
|
||||
if(this.meshModule?.actionHandlers) Object.assign(this, this.meshModule.actionHandlers)
|
||||
this.afterLogin = this.meshModule?.afterLogin ?? []
|
||||
|
||||
this.redisClient = redis.createClient({
|
||||
socket: {
|
||||
@@ -56,7 +58,7 @@ export class RedisConnexion {
|
||||
console.log(`[${this.redisConfig.redisId}] Redis ${this.redisConfig.redisId} time:`, redisTime)
|
||||
}
|
||||
|
||||
for(const method of this.afterLoginMethods){
|
||||
for(const method of this.afterLogin){
|
||||
if(typeof method != 'function') continue
|
||||
method(this)
|
||||
}
|
||||
@@ -282,7 +284,11 @@ export class RedisConnexion {
|
||||
}
|
||||
|
||||
if(typeof(this.meshModule?.dispatchMessage) === 'function') {
|
||||
this.meshModule.dispatchMessage(this, msg, chan)
|
||||
try {
|
||||
await this.meshModule.dispatchMessage(this, msg, chan)
|
||||
} catch(err) {
|
||||
console.error(`[${this.redisConfig.redisId}] dispatchMessage failed on ${chan}:`, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user