MCPcopy Create free account
hub / github.com/e2wugui/zeze / groupByServer

Method groupByServer

ZezeJava/ZezeJava/src/main/java/Zeze/Arch/Online.java:1370–1398  ·  view source on GitHub ↗
(@NotNull Collection<BLoginKey> accounts)

Source from the content-addressed store, hash-verified

1368 }
1369
1370 public @NotNull IntHashMap<RoleOnServer> groupByServer(@NotNull Collection<BLoginKey> accounts) {
1371 var groups = new IntHashMap<RoleOnServer>();
1372 var groupNotOnline = new RoleOnServer(); // LinkName is Empty And Socket is null.
1373 groups.put(groupNotOnline.serverId, groupNotOnline);
1374
1375 for (var account : accounts) {
1376 var online = getOnline(account.getAccount());
1377 if (online == null || online.getLogins().isEmpty()) {
1378 // null != online 意味着这里肯定不为0,不会到达这个分支。
1379 // 下面要求Logins.Count必须大于0,判断一下吧。
1380 groupNotOnline.accounts.add(account);
1381 continue;
1382 }
1383 var login = online.getLogins().get(account.getClientId());
1384 if (null == login) {
1385 groupNotOnline.accounts.add(account);
1386 continue;
1387 }
1388 var serverId = login.getServerId();
1389 // 后面保存connector.Socket并使用,如果之后连接被关闭,以后发送协议失败。
1390 var group = groups.get(serverId);
1391 if (group == null) {
1392 group = new RoleOnServer(serverId);
1393 groups.put(serverId, group);
1394 }
1395 group.accounts.add(account);
1396 }
1397 return groups;
1398 }
1399
1400 private static @NotNull RoleOnServer merge(@Nullable RoleOnServer current, @NotNull RoleOnServer m) {
1401 if (current == null)

Callers 1

transmitInProcedureMethod · 0.95

Calls 10

putMethod · 0.95
getOnlineMethod · 0.95
getMethod · 0.95
getAccountMethod · 0.65
isEmptyMethod · 0.65
addMethod · 0.65
getMethod · 0.65
getClientIdMethod · 0.65
getServerIdMethod · 0.65
getLoginsMethod · 0.45

Tested by

no test coverage detected