Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: show correct log for outbound message #272

Merged
merged 11 commits into from
Dec 14, 2022
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,18 @@ export default async function (event) {
},
}
}],
reply: [
Souvikns marked this conversation as resolved.
Show resolved Hide resolved
{
channel: '/',
payload: {
type: 'likes_count_updated',
data: {
postId,
totalCount
}
}
}
],
Souvikns marked this conversation as resolved.
Show resolved Hide resolved
...(
type === 'like' && {
send: [{
Expand Down
4 changes: 2 additions & 2 deletions examples/social-network/websocket-server/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion src/lib/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,14 @@ export const logInboundMessage = (message: GleeMessage) => {
}

export const logOutboundMessage = (message: GleeMessage) => {
let verb: string
const event = message.eventNames()[0]
const icon = message.broadcast ? '⇶' : '↗'
const verb = message.broadcast ? 'broadcasted' : 'sent'
if (message.serverName === 'websockets' && event !== 'reply') {
Souvikns marked this conversation as resolved.
Show resolved Hide resolved
verb = 'broadcasted'
} else {
verb = 'sent'
}
const serverName = message.serverName || 'all servers'
console.log(chalk.reset.magenta(icon), chalk.yellow(message.channel), 'was', verb ,'to', chalk.gray(serverName))
logJSON(message.payload)
Expand Down