mirror of https://github.com/Ale32bit/Soqet.git
Compare commits
No commits in common. "bb229bbcf8330c1cef8145d936ae11940f36a589" and "dff0d92474ddcc991df2d51c93c994558c782c8b" have entirely different histories.
bb229bbcf8
...
dff0d92474
|
@ -5,6 +5,7 @@
|
||||||
"enableWebsocket": true,
|
"enableWebsocket": true,
|
||||||
"enableTCPSocket": true,
|
"enableTCPSocket": true,
|
||||||
"enablePolling": true,
|
"enablePolling": true,
|
||||||
|
"wildcardChannel": "*",
|
||||||
"pollingInterval": 3600,
|
"pollingInterval": 3600,
|
||||||
"enablePrometheus": true
|
"enablePrometheus": true
|
||||||
}
|
}
|
||||||
|
|
|
@ -186,6 +186,7 @@
|
||||||
<h3>Opening a channel</h3>
|
<h3>Opening a channel</h3>
|
||||||
<div class="sub">
|
<div class="sub">
|
||||||
<p>Opening channels allows the receiving of messages from other clients.</p>
|
<p>Opening channels allows the receiving of messages from other clients.</p>
|
||||||
|
<p>The <b>Wildcard</b> to listen to all channels is <code>*</code>.</p>
|
||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Field</th>
|
<th>Field</th>
|
||||||
|
|
|
@ -41,6 +41,7 @@ export interface Server {
|
||||||
enableWebsocket: boolean,
|
enableWebsocket: boolean,
|
||||||
enableTCPSocket: boolean,
|
enableTCPSocket: boolean,
|
||||||
enablePolling: boolean,
|
enablePolling: boolean,
|
||||||
|
wildcardChannel: string,
|
||||||
pollingInterval: number,
|
pollingInterval: number,
|
||||||
enablePrometheus: boolean,
|
enablePrometheus: boolean,
|
||||||
},
|
},
|
||||||
|
|
20
src/index.ts
20
src/index.ts
|
@ -114,6 +114,11 @@ function transmitMessage(sessionId: string, channel: string | number, message: a
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (channel === config.wildcardChannel) return {
|
||||||
|
ok: false,
|
||||||
|
error: config.wildcardChannel + " is read-only",
|
||||||
|
}
|
||||||
|
|
||||||
// Build the message meta
|
// Build the message meta
|
||||||
let meta: MetaMessage = (rawMeta || {}) as MetaMessage;
|
let meta: MetaMessage = (rawMeta || {}) as MetaMessage;
|
||||||
|
|
||||||
|
@ -147,6 +152,21 @@ function transmitMessage(sessionId: string, channel: string | number, message: a
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Send message to wildcard channel
|
||||||
|
|
||||||
|
let wildcardChannelArray = server.channels[config.wildcardChannel];
|
||||||
|
if (wildcardChannelArray) {
|
||||||
|
wildcardChannelArray.forEach(recipientId => {
|
||||||
|
server.clients[recipientId]?.send({
|
||||||
|
type: "message",
|
||||||
|
channel: config.wildcardChannel,
|
||||||
|
message: message,
|
||||||
|
meta: meta,
|
||||||
|
})
|
||||||
|
server.prometheus.messagesTrafficCounter.labels('outgoing').inc();
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
ok: true,
|
ok: true,
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue