Skip to content

Commit

Permalink
Merge pull request #1 from lynzhlang/feature
Browse files Browse the repository at this point in the history
pull req to GitHub
  • Loading branch information
lynzhlang authored Jan 23, 2025
2 parents 1e0c196 + 786b246 commit e99ef37
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions src/socket.io/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,18 +155,22 @@ function deserializePayload(payload) {
return { params, callback };
}

function isEvent(socket, payload) {
const { event, callback } = payload;
if (!event) {
return winston.warn('[socket.io] Empty method name');
}

if (typeof event !== 'string') {
const escapedName = validator.escape(typeof event);
return callback({ message: `[[error:invalid-event, ${escapedName}]]` });
}
}
async function onMessage(socket, payload) {
console.log('LYNN ZHANG!!!!');
const { event, params, callback } = payload;
try {
if (!event) {
return winston.warn('[socket.io] Empty method name');
}

if (typeof event !== 'string') {
const escapedName = validator.escape(typeof event);
return callback({ message: `[[error:invalid-event, ${escapedName}]]` });
}

isEvent(socket, payload);
const parts = event.split('.');
const namespace = parts[0];
const methodToCall = parts.reduce((prev, cur) => {
Expand Down

0 comments on commit e99ef37

Please sign in to comment.