简体   繁体   English

Kryonet连接ID限制?

[英]Kryonet connection ID limit?

I'm using kryonet for my LibGDX project. 我正在为我的LibGDX项目使用kryonet。 Every time a client connects to the server, a new connection ID gets created. 每次客户端连接到服务器时,都会创建一个新的连接ID。 Eg. 例如。 Client 1: ID 1. Client 2: ID 2. 客户端1:ID 1.客户端2:ID 2。

When a client reconnects, the counter continues, it does not seem to reuse older IDs. 当客户端重新连接时,计数器继续,它似乎不重用旧的ID。 Eg. 例如。 Client 1 reconnects: ID 3. 客户端1重新连接:ID 3。

Does kryonet reset the counter after a while? 一段时间后,kryonet会重置计数器吗? Or is there any way to reset the counter? 或者有没有办法重置柜台? I'm worried about running into issues after my server has been running for a little while. 在我的服务器运行一段时间之后,我担心会遇到问题。

I have solved my own problem but I will leave it here if anyone is interested. 我已经解决了我自己的问题,但如果有人有兴趣我会把它留在这里。

I was looking through the source of Kryonet and found this: 我正在浏览Kryonet的来源并发现了这个:

int id = nextConnectionID++;
if (nextConnectionID == -1) nextConnectionID = 1;

When this value reaches the maximum value, it flips to the minimum value. 当此值达到最大值时,它将翻转为最小值。 Ref: https://stackoverflow.com/a/5131206/4697327 . 参考: https//stackoverflow.com/a/5131206/4697327

I guess there will never be a problem. 我想永远不会有问题。

EDIT: Kryonet uses -1 as ID when the Connection has never been made. 编辑:当从未进行连接时,Kryonet使用-1作为ID。 If the nextConnectionID counts up to 32 bits max value, then flips to it's minimum value and counts up to 0 again, it will pass -1 at some point. 如果nextConnectionID计数最多32位最大值,则翻转到它的最小值并再次计数到0,它将在某个时刻传递-1。 This will be a problem for one connection. 对于一个连接,这将是一个问题。 I haven't found a problem with negative ID's yet. 我还没有发现负面ID的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM