* Make sure the connection limit is not reached with this connection. * Return a boolean wether the user can connect or not.
(ws: WebSocket)
| 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. |
no test coverage detected