Skip to content

Commit

Permalink
chore: update socketModule
Browse files Browse the repository at this point in the history
  • Loading branch information
ynwd committed Oct 30, 2024
1 parent 7b91ba8 commit 72b4947
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion modules/socket/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,10 @@ export default function socketModule(s: Fastro) {
socket.onmessage = async (event) => {
const data: Data = JSON.parse(event.data);
joinRoom(ctx, socket, data.room);
await injectData(ctx, data);
if (data.type === "message" && data.message?.msg !== "") {
broadcastMessage(data.room, JSON.stringify(data.message));
}
await injectData(ctx, data);
};
socket.onclose = () => console.log("DISCONNECTED");
socket.onerror = (error) => console.error("ERROR:", error);
Expand Down

0 comments on commit 72b4947

Please sign in to comment.