refactor: 将端口和在线ID类型从uint16改为uint32
Some checks failed
ci/woodpecker/push/my-first-workflow Pipeline failed

This commit is contained in:
xinian
2026-03-02 18:34:20 +08:00
committed by cnb
parent ae06d18aa2
commit 47bc680889
12 changed files with 35 additions and 35 deletions

View File

@@ -34,7 +34,7 @@ func (*ServerHandler) Kick(_ context.Context, userid uint32) error {
}
// 注册logic服务器
func (*ServerHandler) RegisterLogic(ctx context.Context, id, port uint16) error {
func (*ServerHandler) RegisterLogic(ctx context.Context, id, port uint32) error {
fmt.Println("注册logic服务器", id, port)
//TODO 待修复滚动更新可能导致的玩家可以同时在旧服务器和新服务器同时在线的bug
@@ -44,11 +44,11 @@ func (*ServerHandler) RegisterLogic(ctx context.Context, id, port uint16) error
}
t := config.NewServerService().GetServerID((id))
aa, ok := cool.GetClient(t.Port)
aa, ok := cool.GetClient(t.OnlineID*100000 + t.Port)
if ok && aa != nil { //如果已经存在且这个端口已经被存过
aa.QuitSelf(0)
}
cool.AddClient(port, &revClient)
cool.AddClient(100000*id+port, &revClient)
//Refurh()
return nil
@@ -67,10 +67,10 @@ func CServer() *jsonrpc.RPCServer {
var closer jsonrpc.ClientCloser
func StartClient(id, port uint16, callback any) *struct {
func StartClient(id, port uint32, callback any) *struct {
Kick func(uint32) error
RegisterLogic func(uint16, uint16) error
RegisterLogic func(uint32, uint32) error
} {
// cool.Config.File.Domain = "127.0.0.1"
var rpcaddr = "ws://" + cool.Config.File.Domain + gconv.String(cool.Config.Address) + "/rpc"
@@ -99,7 +99,7 @@ func StartClient(id, port uint16, callback any) *struct {
var RPCClient struct {
Kick func(uint32) error //踢人
RegisterLogic func(uint16, uint16) error
RegisterLogic func(uint32, uint32) error
// UserLogin func(int32, int32) error //用户登录事件
// UserLogout func(int32, int32) error //用户登出事件