mirror of
https://github.com/AynaLivePlayer/AynaLivePlayer.git
synced 2025-12-06 18:32:50 +08:00
24 lines
447 B
Go
24 lines
447 B
Go
package controller
|
|
|
|
import (
|
|
"AynaLivePlayer/event"
|
|
"AynaLivePlayer/liveclient"
|
|
)
|
|
|
|
var DanmuHandlers []DanmuHandler
|
|
|
|
type DanmuHandler interface {
|
|
Execute(anmu *liveclient.DanmuMessage)
|
|
}
|
|
|
|
func AddDanmuHandler(handlers ...DanmuHandler) {
|
|
DanmuHandlers = append(DanmuHandlers, handlers...)
|
|
}
|
|
|
|
func danmuHandler(event *event.Event) {
|
|
danmu := event.Data.(*liveclient.DanmuMessage)
|
|
for _, cmd := range DanmuHandlers {
|
|
cmd.Execute(danmu)
|
|
}
|
|
}
|