接收一个协议(尚未处理)时,判断单个socket是否接收超限 @return 是否检查通过, false则丢弃该协议(也可以同时关闭连接)
(@NotNull AsyncSocket sender, int moduleId, int protocolId, int size)
| 820 | * @return 是否检查通过, false则丢弃该协议(也可以同时关闭连接) |
| 821 | */ |
| 822 | @SuppressWarnings("MethodMayBeStatic") |
| 823 | public boolean checkThrottle(@NotNull AsyncSocket sender, int moduleId, int protocolId, int size) { |
| 824 | var throttle = sender.getTimeThrottle(); |
| 825 | if (null != throttle && !throttle.checkNow(size)) { |
| 826 | // trySendResultCode(Procedure.Busy); // 超过速度限制,不报告错误。因为可能是一种攻击。 |
| 827 | sender.close(throttleException); // 默认关闭连接。 |
| 828 | return false; // 超过速度控制,丢弃这条协议。 |
| 829 | } |
| 830 | return true; |
| 831 | } |
| 832 | |
| 833 | public boolean discard(@NotNull AsyncSocket sender, int moduleId, int protocolId, int size) throws Exception { |
| 834 | return false; |
no test coverage detected