fix(network): 修复 rpc 和 websocket 地址拼接缺少冒号的问题

修复了 jsonrpc 服务启动时监听地址缺少冒号导致解析错误的问题,
同时修正 websocket 客户端连接地址的拼接逻辑。此外,注释掉了一处日志输出,
并调整了端口检测函数的参数类型以匹配实际配置结构。

```
This commit is contained in:
2025-10-08 17:16:54 +08:00
parent da06241c06
commit a22287d987
5 changed files with 10 additions and 9 deletions

View File

@@ -58,8 +58,8 @@ jobs:
uses: easingthemes/ssh-deploy@main uses: easingthemes/ssh-deploy@main
env: env:
SSH_PRIVATE_KEY: ${{ secrets.BLAZING }} SSH_PRIVATE_KEY: ${{ secrets.BLAZING }}
REMOTE_HOST: "122.10.117.123" REMOTE_HOST: "125.208.20.223"
REMOTE_PORT: 41967 REMOTE_PORT: 22916
REMOTE_USER: "root" REMOTE_USER: "root"
SOURCE: "logic_${{ needs.prepare-version.outputs.build_version }}" # 只指定可执行文件作为源 SOURCE: "logic_${{ needs.prepare-version.outputs.build_version }}" # 只指定可执行文件作为源
TARGET: "/home/" TARGET: "/home/"

View File

@@ -68,12 +68,12 @@ func StartServer() {
rpcServer := jsonrpc.NewServer(jsonrpc.WithReverseClient[ClientHandler]("")) rpcServer := jsonrpc.NewServer(jsonrpc.WithReverseClient[ClientHandler](""))
rpcServer.Register("", &ServerHandler{}) rpcServer.Register("", &ServerHandler{})
cool.Loger.Debug(context.Background(), "jsonrpc server start") cool.Loger.Debug(context.Background(), "jsonrpc server start", rpcport)
// go time.AfterFunc(3000, func() { // go time.AfterFunc(3000, func() {
// testjsonrpc() // testjsonrpc()
// }) // })
err := http.ListenAndServe("0.0.0.0"+rpcport, rpcServer) err := http.ListenAndServe("0.0.0.0:"+rpcport, rpcServer)
cool.Loger.Debug(context.Background(), "jsonrpc server fail", err) cool.Loger.Debug(context.Background(), "jsonrpc server fail", err)
} }
@@ -88,7 +88,7 @@ func StartClient(id, port uint16, callback any) *struct {
var rpcaddr, _ = service.NewBaseSysParamService().DataByKey(context.Background(), "server_ip") var rpcaddr, _ = service.NewBaseSysParamService().DataByKey(context.Background(), "server_ip")
closer1, err := jsonrpc.NewMergeClient(context.Background(), closer1, err := jsonrpc.NewMergeClient(context.Background(),
"ws://"+rpcaddr+rpcport, "", []interface{}{ "ws://"+rpcaddr+":"+rpcport, "", []interface{}{
&RPCClient, &RPCClient,
}, nil, jsonrpc.WithClientHandler("", callback), }, nil, jsonrpc.WithClientHandler("", callback),
jsonrpc.WithReconnFun(func() { RPCClient.RegisterLogic(id, port) }), jsonrpc.WithReconnFun(func() { RPCClient.RegisterLogic(id, port) }),

View File

@@ -59,7 +59,7 @@ func (s *Server) OnTick() (delay time.Duration, action gnet.Action) {
func (s *Server) OnBoot(eng gnet.Engine) gnet.Action { func (s *Server) OnBoot(eng gnet.Engine) gnet.Action {
s.eng = eng s.eng = eng
cool.Loger.Infof(context.Background(), " server is listening on %s\n", s.addr) // cool.Loger.Infof(context.Background(), " server is listening on %s\n", s.addr)
return gnet.None return gnet.None
} }

View File

@@ -24,7 +24,7 @@ const (
) )
var defaultPort = gconv.Int(cool.Config.Port) //读入默认的端口 var defaultPort = gconv.Int(cool.Config.Port) //读入默认的端口
var candidatePorts = []int{defaultPort} var candidatePorts = cool.Config.GamePort
// determinePort 确定服务器使用的端口 // determinePort 确定服务器使用的端口
func determinePort(serverid uint16) (int, error) { func determinePort(serverid uint16) (int, error) {
@@ -38,7 +38,7 @@ func determinePort(serverid uint16) (int, error) {
// 遍历指定的端口列表 // 遍历指定的端口列表
for _, port := range candidatePorts { for _, port := range candidatePorts {
if isPortAvailable(port) { if isPortAvailable(port) {
return port, nil return int(port), nil
} }
log.Printf("Port %d is not available, checking next...", port) log.Printf("Port %d is not available, checking next...", port)
} }
@@ -49,7 +49,7 @@ func determinePort(serverid uint16) (int, error) {
} }
// isPortAvailable 检查端口是否可用 // isPortAvailable 检查端口是否可用
func isPortAvailable(port int) bool { func isPortAvailable(port uint64) bool {
address := fmt.Sprintf(":%d", port) address := fmt.Sprintf(":%d", port)
listener, err := net.Listen("tcp", address) listener, err := net.Listen("tcp", address)
if err != nil { if err != nil {

View File

@@ -7,6 +7,7 @@ import "blazing/logic/service/fight/input"
func (e *EffectNode) Fight_Start(ctx input.Ctx) bool { func (e *EffectNode) Fight_Start(ctx input.Ctx) bool {
//战斗开始应该注入魂印 //战斗开始应该注入魂印
//panic("not implemented") // TODO: Implement //panic("not implemented") // TODO: Implement
return true
} }
func (e *EffectNode) PreBattleEnd(ctx input.Ctx) bool { func (e *EffectNode) PreBattleEnd(ctx input.Ctx) bool {
panic("not implemented") // TODO: Implement panic("not implemented") // TODO: Implement