DNF90 服务端与启动器完整源码(含 GM 工具功能增强)
服务端(Go): - GM 塞背包/带属性装备发放:在线角色推送 op14 增量物品行,背包实时刷新,无需回角色选择界面 - GM 改金币/改等级:去掉在线拒绝,落库后推送 op14 钱包/op37 等级状态,在线实时刷新 - 等级端点统一切换到新版 GMSetCharacterLevel(自带在线刷新) - 无限/锁死疲劳模式 + 燃烧疲劳:每房间消耗 2 点、打怪与通关经验双倍 - 燃烧疲劳开关时给所有在线角色推送系统提示(op12 mode 0) - 深渊史诗掉率:GM 全局倍率 + 城镇增益药剂窗口倍率,真实接入掉落结算 启动器(Python/JS): - 标题栏自绘、窗口 1204x717、禁止拖拽改大小、仅最小化/关闭 - GM 工具:疲劳与燃烧、深渊史诗掉率、拍卖行上架(单一定价对齐) - 拍卖行上架前端对齐服务端单一价格语义,修复 400 报错
This commit is contained in:
commit
645b64fe21
4388 files changed
+1405457
No files matched your search
@@ -0,0 +1,81 @@
|
||||
package rpc
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"longheng.io/server/internal/platform/bus"
|
||||
"longheng.io/server/pkg/contracts"
|
||||
)
|
||||
|
||||
// RequestHandler 是 transport 收到 RPC 请求后的回调。
|
||||
type RequestHandler func(context.Context, contracts.RPCRequest) error
|
||||
|
||||
// ResponseHandler 是 transport 收到 RPC 响应后的回调。
|
||||
type ResponseHandler func(context.Context, contracts.RPCResponse) error
|
||||
|
||||
// TransportSubscription 表示可关闭的 transport 订阅。
|
||||
type TransportSubscription interface {
|
||||
Close() error
|
||||
}
|
||||
|
||||
// Transport 抽象 RPC 请求和响应的订阅与发布能力。
|
||||
type Transport interface {
|
||||
SubscribeRequests(context.Context, string, RequestHandler) (TransportSubscription, error)
|
||||
SubscribeResponses(context.Context, string, ResponseHandler) (TransportSubscription, error)
|
||||
PublishRequest(context.Context, string, contracts.RPCRequest) error
|
||||
PublishResponse(context.Context, string, contracts.RPCResponse) error
|
||||
}
|
||||
|
||||
// BusTransport 通过框架 bus 投递 RPC 请求和响应。
|
||||
type BusTransport struct {
|
||||
bus bus.Bus
|
||||
}
|
||||
|
||||
// NewBusTransport 创建基于 bus 的 RPC transport。
|
||||
func NewBusTransport(eventBus bus.Bus) *BusTransport {
|
||||
return &BusTransport{bus: eventBus}
|
||||
}
|
||||
|
||||
// SubscribeRequests 订阅指定节点的 RPC 请求主题。
|
||||
func (t *BusTransport) SubscribeRequests(_ context.Context, nodeID string, handler RequestHandler) (TransportSubscription, error) {
|
||||
if t == nil || t.bus == nil {
|
||||
return nil, bus.ErrClosed
|
||||
}
|
||||
return t.bus.Subscribe(contracts.RPCNodeRequestTopic(nodeID), func(ctx context.Context, env bus.Envelope) error {
|
||||
req, ok := rpcReqPayload(env.Payload)
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
return handler(ctx, req)
|
||||
})
|
||||
}
|
||||
|
||||
// SubscribeResponses 订阅指定节点的 RPC 响应主题。
|
||||
func (t *BusTransport) SubscribeResponses(_ context.Context, nodeID string, handler ResponseHandler) (TransportSubscription, error) {
|
||||
if t == nil || t.bus == nil {
|
||||
return nil, bus.ErrClosed
|
||||
}
|
||||
return t.bus.Subscribe(contracts.RPCResponseTopic(nodeID), func(ctx context.Context, env bus.Envelope) error {
|
||||
resp, ok := rpcRespPayload(env.Payload)
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
return handler(ctx, resp)
|
||||
})
|
||||
}
|
||||
|
||||
// PublishRequest 把 RPC 请求发布到目标节点主题。
|
||||
func (t *BusTransport) PublishRequest(ctx context.Context, targetNodeID string, request contracts.RPCRequest) error {
|
||||
if t == nil || t.bus == nil {
|
||||
return bus.ErrClosed
|
||||
}
|
||||
return t.bus.Publish(ctx, contracts.RPCNodeRequestTopic(targetNodeID), request)
|
||||
}
|
||||
|
||||
// PublishResponse 把 RPC 响应发布到目标节点响应主题。
|
||||
func (t *BusTransport) PublishResponse(ctx context.Context, targetNodeID string, response contracts.RPCResponse) error {
|
||||
if t == nil || t.bus == nil {
|
||||
return bus.ErrClosed
|
||||
}
|
||||
return t.bus.Publish(ctx, contracts.RPCResponseTopic(targetNodeID), response)
|
||||
}
|
||||
Reference in new issue
Block a user