```
fix(network): 修复 rpc 和 websocket 地址拼接缺少冒号的问题 修复了 jsonrpc 服务启动时监听地址缺少冒号导致解析错误的问题, 同时修正 websocket 客户端连接地址的拼接逻辑。此外,注释掉了一处日志输出, 并调整了端口检测函数的参数类型以匹配实际配置结构。 ```
This commit is contained in:
4
.github/workflows/logic_CI.yml
vendored
4
.github/workflows/logic_CI.yml
vendored
@@ -58,8 +58,8 @@ jobs:
|
||||
uses: easingthemes/ssh-deploy@main
|
||||
env:
|
||||
SSH_PRIVATE_KEY: ${{ secrets.BLAZING }}
|
||||
REMOTE_HOST: "122.10.117.123"
|
||||
REMOTE_PORT: 41967
|
||||
REMOTE_HOST: "125.208.20.223"
|
||||
REMOTE_PORT: 22916
|
||||
REMOTE_USER: "root"
|
||||
SOURCE: "logic_${{ needs.prepare-version.outputs.build_version }}" # 只指定可执行文件作为源
|
||||
TARGET: "/home/"
|
||||
|
||||
@@ -68,12 +68,12 @@ func StartServer() {
|
||||
rpcServer := jsonrpc.NewServer(jsonrpc.WithReverseClient[ClientHandler](""))
|
||||
|
||||
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() {
|
||||
// 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)
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ func StartClient(id, port uint16, callback any) *struct {
|
||||
var rpcaddr, _ = service.NewBaseSysParamService().DataByKey(context.Background(), "server_ip")
|
||||
|
||||
closer1, err := jsonrpc.NewMergeClient(context.Background(),
|
||||
"ws://"+rpcaddr+rpcport, "", []interface{}{
|
||||
"ws://"+rpcaddr+":"+rpcport, "", []interface{}{
|
||||
&RPCClient,
|
||||
}, nil, jsonrpc.WithClientHandler("", callback),
|
||||
jsonrpc.WithReconnFun(func() { RPCClient.RegisterLogic(id, port) }),
|
||||
|
||||
@@ -59,7 +59,7 @@ func (s *Server) OnTick() (delay time.Duration, action gnet.Action) {
|
||||
func (s *Server) OnBoot(eng gnet.Engine) gnet.Action {
|
||||
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
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ const (
|
||||
)
|
||||
|
||||
var defaultPort = gconv.Int(cool.Config.Port) //读入默认的端口
|
||||
var candidatePorts = []int{defaultPort}
|
||||
var candidatePorts = cool.Config.GamePort
|
||||
|
||||
// determinePort 确定服务器使用的端口
|
||||
func determinePort(serverid uint16) (int, error) {
|
||||
@@ -38,7 +38,7 @@ func determinePort(serverid uint16) (int, error) {
|
||||
// 遍历指定的端口列表
|
||||
for _, port := range candidatePorts {
|
||||
if isPortAvailable(port) {
|
||||
return port, nil
|
||||
return int(port), nil
|
||||
}
|
||||
log.Printf("Port %d is not available, checking next...", port)
|
||||
}
|
||||
@@ -49,7 +49,7 @@ func determinePort(serverid uint16) (int, error) {
|
||||
}
|
||||
|
||||
// isPortAvailable 检查端口是否可用
|
||||
func isPortAvailable(port int) bool {
|
||||
func isPortAvailable(port uint64) bool {
|
||||
address := fmt.Sprintf(":%d", port)
|
||||
listener, err := net.Listen("tcp", address)
|
||||
if err != nil {
|
||||
|
||||
@@ -7,6 +7,7 @@ import "blazing/logic/service/fight/input"
|
||||
func (e *EffectNode) Fight_Start(ctx input.Ctx) bool {
|
||||
//战斗开始应该注入魂印
|
||||
//panic("not implemented") // TODO: Implement
|
||||
return true
|
||||
}
|
||||
func (e *EffectNode) PreBattleEnd(ctx input.Ctx) bool {
|
||||
panic("not implemented") // TODO: Implement
|
||||
|
||||
Reference in New Issue
Block a user