MCPcopy
hub / github.com/soketi/soketi / checkAppConnectionLimit

Method checkAppConnectionLimit

src/ws-handler.ts:744–757  ·  view source on GitHub ↗

* Make sure the connection limit is not reached with this connection. * Return a boolean wether the user can connect or not.

(ws: WebSocket)

Source from the content-addressed store, hash-verified

742 * Return a boolean wether the user can connect or not.
743 */
744 protected checkAppConnectionLimit(ws: WebSocket): Promise<boolean> {
745 return this.server.adapter.getSocketsCount(ws.app.id).then(wsCount => {
746 let maxConnections = parseInt(ws.app.maxConnections as string) || -1;
747
748 if (maxConnections < 0) {
749 return true;
750 }
751
752 return wsCount + 1 <= maxConnections;
753 }).catch(err => {
754 Log.error(err);
755 return false;
756 });
757 }
758
759 /**
760 * Check is an incoming connection can subscribe.

Callers 1

onOpenMethod · 0.95

Calls 2

errorMethod · 0.80
getSocketsCountMethod · 0.65

Tested by

no test coverage detected