Skip to content

Commit

Permalink
优化代码,增加通过名称获取通知插件的方法
Browse files Browse the repository at this point in the history
  • Loading branch information
microrain authored and microrain committed Aug 19, 2023
1 parent 786e82b commit e93e7d5
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
25 changes: 24 additions & 1 deletion extend/extend.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func pluginInit(sysPluginType string) (pm *Manager, err error) {
return
}

// GetProtocolPlugin 获取指协议名称的插件
// Deprecated: GetProtocolPlugin 这个方法已经废弃,不建议使用。请使用GetProtocolByName
func (pm *SysPlugin) GetProtocolPlugin(protocolName string) (obj module.Protocol, err error) {
//获取插件
p, err := pm.pluginManager.GetInterface(protocolName)
Expand All @@ -87,6 +87,29 @@ func (pm *SysPlugin) GetProtocolPlugin(protocolName string) (obj module.Protocol
return
}

// GetProtocolByName 获取指协议名称的插件
func (pm *SysPlugin) GetProtocolByName(protocolName string) (obj module.Protocol, err error) {
//获取插件
p, err := pm.pluginManager.GetInterface(protocolName)
if err != nil {
return
}
obj = p.(module.Protocol)
return
}

// GetNoticeByName 获取指定通知名称的插件
func (pm *SysPlugin) GetNoticeByName(noticeName string) (obj module.Notice, err error) {
//获取插件
p, err := pm.pluginManager.GetInterface(noticeName)
if err != nil {
g.Log().Error(context.Background(), err.Error())
return
}
obj = p.(module.Notice)
return
}

// GetProtocolUnpackData 通过协议解析插件处理后,获取解析数据。protocolType 为协议名称
// todo 需要标记数据协议子类型
func (pm *SysPlugin) GetProtocolUnpackData(protocolType string, data []byte) (res model.JsonRes, err error) {
Expand Down
2 changes: 0 additions & 2 deletions plugins/built/.gitignore

This file was deleted.

Empty file added plugins/built/.gitkeep
Empty file.

0 comments on commit e93e7d5

Please sign in to comment.