blasphem/pkg/blas/core/core.go

52 lines
1 KiB
Go
Raw Normal View History

2022-12-20 16:26:04 -05:00
package core
import (
"context"
"dynatron.me/x/blasphem/pkg/auth"
"dynatron.me/x/blasphem/pkg/bus"
"dynatron.me/x/blasphem/pkg/components"
"dynatron.me/x/blasphem/pkg/config"
"dynatron.me/x/blasphem/pkg/storage"
2022-12-20 20:30:58 -05:00
"github.com/gorilla/websocket"
2022-12-20 16:26:04 -05:00
)
2022-12-20 19:05:45 -05:00
type Blas interface {
2022-12-20 16:26:04 -05:00
auth.Authenticator
bus.Bus
storage.Store
config.Configured
2022-12-20 19:05:45 -05:00
components.Componenter
WebSocketManager
2022-12-20 16:26:04 -05:00
Shutdowner
Versioner
}
2022-12-20 19:05:45 -05:00
type WebSocketManager interface {
// Register registers a websocket command.
// cmd is the first part, before first slash
// dataNew is a function to create a new message datatype
RegisterWSCommand(cmd string, hnd Handler, dataNew NewData)
2022-12-20 20:34:45 -05:00
WSCommandHandler(cmd string, splitCmd []string) (NewData, Handler, error)
2022-12-20 19:05:45 -05:00
}
type WebSocketSession interface {
2022-12-20 20:30:58 -05:00
WSConn() *websocket.Conn
2022-12-20 19:05:45 -05:00
Go() error
Blas() Blas
}
2022-12-20 20:30:58 -05:00
type Handler func(wss WebSocketSession, msgID int, cmd []string, msg interface{}) error
type NewData func(cmd []string) interface{}
2022-12-20 19:05:45 -05:00
2022-12-20 16:26:04 -05:00
type Shutdowner interface {
ShutdownBlas(context.Context) error
}
type Versioner interface {
Version() string
}