package server import ( "github.com/noahlann/nnet/internal/codec" internalprotocol "github.com/noahlann/nnet/internal/protocol" "github.com/noahlann/nnet/internal/protocol/nnet" codecpkg "github.com/noahlann/nnet/pkg/codec" "github.com/noahlann/nnet/pkg/config" protocolpkg "github.com/noahlann/nnet/pkg/protocol" ) // initCodecRegistry 初始化编解码器注册表 func initCodecRegistry(cfg *config.Config) codecpkg.Registry { // 创建编解码器注册表 codecRegistry := codec.NewRegistry() // 注册Protobuf和MessagePack编解码器(如果可用) protobufCodec := codec.NewProtobufCodec() codecRegistry.Register("protobuf", protobufCodec) msgpackCodec := codec.NewMessagePackCodec() codecRegistry.Register("msgpack", msgpackCodec) return codecRegistry } // initProtocolManager 初始化协议管理器 // 协议管理器只管理应用层协议(如nnet协议),不管理传输层协议(TCP、UDP、WebSocket) func initProtocolManager() protocolpkg.Manager { // 创建协议管理器 protocolManager := internalprotocol.NewManager() // 注册nnet协议(应用层协议) nnetProtocol := nnet.NewNNetProtocol("1.0") protocolManager.Register(nnetProtocol) return protocolManager }