Comparing version 0.1.11 to 0.1.12
@@ -13,2 +13,3 @@ "use strict"; | ||
agent.beforeStart(() => { | ||
agent.logger.info('[egg-ez-ws] agent init...'); | ||
const clusterManager = egg_aop_1.getInstance(lib_1.ClusterManager, agent, undefined); | ||
@@ -27,8 +28,11 @@ // 注册默认事件处理器 | ||
clusterManager.onSendTo.addHandler(evt => { | ||
agent.logger.debug('[egg-ez-ws] agent onSendTo', evt.type, evt.id); | ||
agent.messenger.sendToApp(contract_1.MESSAGE_EVENT, evt); | ||
}); | ||
agent.messenger.on(contract_1.MESSAGE_EVENT, evt => { | ||
agent.logger.debug('[egg-ez-ws] agent on MESSAGE_EVENT', evt.type, evt.id); | ||
clusterManager.eventProcess(evt); | ||
}); | ||
agent.logger.info('[egg-ez-ws] agent init ok'); | ||
}); | ||
}; |
@@ -13,2 +13,3 @@ "use strict"; | ||
exports.default = (app) => { | ||
app.logger.info('[egg-ez-ws] app init...'); | ||
const clientManager = egg_aop_1.getInstance(lib_1.ClientManager, app, undefined); | ||
@@ -25,5 +26,7 @@ // 注册默认事件处理器 | ||
clientManager.onSendTo.addHandler(evt => { | ||
app.logger.debug('[egg-ez-ws] app onSendTo', evt.type, evt.id); | ||
app.messenger.sendToAgent(contract_1.MESSAGE_EVENT, evt); | ||
}); | ||
app.messenger.on(contract_1.MESSAGE_EVENT, evt => { | ||
app.logger.debug('[egg-ez-ws] app on MESSAGE_EVENT', evt.type, evt.id); | ||
clientManager.eventProcess(evt); | ||
@@ -37,2 +40,3 @@ }); | ||
}); | ||
app.logger.info('[egg-ez-ws] app init ok'); | ||
}; |
@@ -7,2 +7,5 @@ declare const _default: (app: any) => { | ||
customLogger: { | ||
BaseManager: { | ||
file: string; | ||
}; | ||
ClusterManager: { | ||
@@ -9,0 +12,0 @@ file: string; |
@@ -11,2 +11,5 @@ "use strict"; | ||
customLogger: { | ||
BaseManager: { | ||
file: path.join(app.root, `logs/ez-ws/base-manager.log`), | ||
}, | ||
ClusterManager: { | ||
@@ -13,0 +16,0 @@ file: path.join(app.root, `logs/ez-ws/cluster-manager.log`), |
@@ -86,17 +86,21 @@ "use strict"; | ||
}), A_W_1.RoomInfoResponseEvent); | ||
if (!info) { | ||
return; | ||
const response = { | ||
type: 'ROOM_INFO', | ||
success: false, | ||
data: {}, | ||
}; | ||
if (!info || !info.data) { | ||
response.data = { err: 'NOT_FOUND_ROOM' }; | ||
} | ||
if (!client.isAdmin && (info.data.clients || []).every(c => c.id !== client.id)) { | ||
return; | ||
else if (!client.isAdmin && (info.data.clients || []).every(c => c.id !== client.id)) { | ||
response.data = { err: 'FORBIDDEN' }; | ||
} | ||
const response = { | ||
type: 'ROOM_INFO', | ||
success: true, | ||
data: { | ||
else { | ||
response.success = true; | ||
response.data = { | ||
id: info.data.id, | ||
info: info.data.info, | ||
clients: info.data.clients.map(c => ({ id: c.id, info: c.info })), | ||
}, | ||
}; | ||
}; | ||
} | ||
client.sendMessage(response, evt.evtId); | ||
@@ -103,0 +107,0 @@ }); |
@@ -16,19 +16,18 @@ "use strict"; | ||
const room = yield this.manager.getRoom(evt.data.roomId); | ||
if (!room) { | ||
return; | ||
} | ||
return new A_W_1.RoomInfoResponseEvent({ | ||
id: room.id, | ||
info: room.ext.info, | ||
data: room.ext.data, | ||
gmtCreated: room.ext.gmtCreated, | ||
clients: [...room.clients.values()].map(c => { | ||
return { | ||
id: c.id, | ||
info: c.ext.info, | ||
data: c.ext.data, | ||
gmtCreated: c.ext.gmtCreated, | ||
}; | ||
}), | ||
}, evt.id); | ||
return new A_W_1.RoomInfoResponseEvent(room | ||
? { | ||
id: room.id, | ||
info: room.ext.info, | ||
data: room.ext.data, | ||
gmtCreated: room.ext.gmtCreated, | ||
clients: [...room.clients.values()].map(c => { | ||
return { | ||
id: c.id, | ||
info: c.ext.info, | ||
data: c.ext.data, | ||
gmtCreated: c.ext.gmtCreated, | ||
}; | ||
}), | ||
} | ||
: null, evt.id); | ||
}); | ||
@@ -35,0 +34,0 @@ } |
{ | ||
"name": "egg-ez-ws", | ||
"version": "0.1.11", | ||
"version": "0.1.12", | ||
"description": "easy websocket for egg.", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
65691
1635