Skip to content

Commit

Permalink
chore: debug broadcastMessage on prod
Browse files Browse the repository at this point in the history
  • Loading branch information
ynwd committed Dec 7, 2024
1 parent e1afc11 commit c95f3da
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
4 changes: 1 addition & 3 deletions core/server/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,9 @@ export default class Server implements Fastro {
this.serverOptions = options ?? {};
this.#handler = this.#createHandler();
this.#addPropsEndpoint();
this.#nonce = ulid();
}
getNonce(): string {
if (this.#nonce === "") {
this.#nonce = ulid();
}
return this.#nonce;
}
get(
Expand Down
5 changes: 3 additions & 2 deletions modules/socket/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default function socketModule(s: Fastro) {
for (const key in entries) {
const [, { socket }] = entries[key];
if (socket.readyState === WebSocket.OPEN) {
console.log("s.getNonce:", s.getNonce());
// console.log("s.getNonce:", s.getNonce());
socket.send(message);
} else {
socket.close();
Expand All @@ -38,6 +38,7 @@ export default function socketModule(s: Fastro) {
socket: WebSocket,
) {
connected.set(data.user, { data, socket });
console.log(`connected ${s.getNonce()}:`, connected);
const entries = connected.entries().toArray();
const cc = Array.from(entries).map(([, { data }]) => ({
username: data.username,
Expand All @@ -48,7 +49,7 @@ export default function socketModule(s: Fastro) {
for (const key in entries) {
const [, { socket }] = entries[key];
if (socket.readyState === WebSocket.OPEN) {
console.log("s.getNonce:", s.getNonce());
// console.log("s.getNonce:", s.getNonce());
socket.send(JSON.stringify(cc));
} else {
socket.close();
Expand Down

0 comments on commit c95f3da

Please sign in to comment.