mirror of
https://github.com/tiennm99/zfoo.git
synced 2026-08-21 06:27:36 +00:00
fix[module] 修复:再有连接时,优先以uid作为hashId
This commit is contained in:
@@ -96,8 +96,8 @@ public class Session implements Closeable {
|
||||
}
|
||||
|
||||
|
||||
public Object getAttribute(AttributeType key) {
|
||||
return attributes.get(key);
|
||||
public <T> T getAttribute(AttributeType key) {
|
||||
return (T) attributes.get(key);
|
||||
}
|
||||
|
||||
public Channel getChannel() {
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
|
||||
package com.zfoo.net.task.dispatcher;
|
||||
|
||||
import com.zfoo.net.session.model.AttributeType;
|
||||
import com.zfoo.net.task.TaskBus;
|
||||
import com.zfoo.net.task.model.PacketReceiverTask;
|
||||
|
||||
@@ -35,7 +36,14 @@ public class ConsistentHashTaskDispatch extends AbstractTaskDispatch {
|
||||
var attachment = packetReceiverTask.getAttachment();
|
||||
|
||||
if (attachment == null) {
|
||||
return SessionIdTaskDispatch.getInstance().getExecutor(packetReceiverTask);
|
||||
var session = packetReceiverTask.getSession();
|
||||
Long uid = session.getAttribute(AttributeType.UID);
|
||||
|
||||
if (uid == null) {
|
||||
return SessionIdTaskDispatch.getInstance().getExecutor(packetReceiverTask);
|
||||
} else {
|
||||
return TaskBus.executor(Math.toIntExact(uid));
|
||||
}
|
||||
}
|
||||
|
||||
// 可见最终是根据附加包的信息选择服务端由哪个线程执行这个业务
|
||||
|
||||
Reference in New Issue
Block a user