Closed maxbad closed 2 months ago
设置一个小顶堆来存所有空闲连接,以给每一个连接设置一个过期时间,这个时间堆就用这个过期时间来排序,在 OnTick()
中每次取出一个,用过期时间减去当前时间得到一个差值 d
并作为返回值,OnTick()
就会在 d
时间之后再次调用,取出堆顶的空闲连接并销毁。
🤖 Non-English text detected, translating...
Set up a small top heap to store all idle connections, and set an expiration time for each connection. This time heap is sorted by this expiration time. Take out one at a time in
OnTick()
, and use the expiration time minus the current The time gets a difference valued
as the return value.OnTick()
will be called again afterd
time, taking out the idle connection on the top of the heap and destroying it.
Description of new feature
没有找到获取当前全部连接的接口, 怎么实现踢掉长时间没有数据交互的连接呢, 是需要上线存到列表, 然后遍历自己的列表吗
Scenarios for new feature
TCP长连接
Breaking changes or not?
No
Code snippets (optional)
No response
Alternatives for new feature
None.
Additional context (optional)
None.