mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
start file refactor.
This commit is contained in:
parent
894c0f28dc
commit
e852afcf2a
@ -117,10 +117,10 @@ func init() {
|
|||||||
logger.Info().Msg("preflight complete")
|
logger.Info().Msg("preflight complete")
|
||||||
}
|
}
|
||||||
|
|
||||||
neko.Service.Root.Set()
|
neko.Service.Configs.Root.Set()
|
||||||
})
|
})
|
||||||
|
|
||||||
if err := neko.Service.Root.Init(root); err != nil {
|
if err := neko.Service.Configs.Root.Init(root); err != nil {
|
||||||
log.Panic().Err(err).Msg("unable to run root command")
|
log.Panic().Err(err).Msg("unable to run root command")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
10
cmd/serve.go
10
cmd/serve.go
@ -17,11 +17,11 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
configs := []config.Config{
|
configs := []config.Config{
|
||||||
neko.Service.Server,
|
neko.Service.Configs.Server,
|
||||||
neko.Service.WebRTC,
|
neko.Service.Configs.WebRTC,
|
||||||
neko.Service.Remote,
|
neko.Service.Configs.Remote,
|
||||||
neko.Service.Broadcast,
|
neko.Service.Configs.Broadcast,
|
||||||
neko.Service.WebSocket,
|
neko.Service.Configs.WebSocket,
|
||||||
}
|
}
|
||||||
|
|
||||||
cobra.OnInitialize(func() {
|
cobra.OnInitialize(func() {
|
||||||
|
73
neko.go
73
neko.go
@ -59,12 +59,14 @@ func init() {
|
|||||||
Compiler: runtime.Compiler,
|
Compiler: runtime.Compiler,
|
||||||
Platform: fmt.Sprintf("%s/%s", runtime.GOOS, runtime.GOARCH),
|
Platform: fmt.Sprintf("%s/%s", runtime.GOOS, runtime.GOARCH),
|
||||||
},
|
},
|
||||||
|
Configs: &Configs{
|
||||||
Root: &config.Root{},
|
Root: &config.Root{},
|
||||||
Server: &config.Server{},
|
Server: &config.Server{},
|
||||||
Remote: &config.Remote{},
|
Remote: &config.Remote{},
|
||||||
Broadcast: &config.Broadcast{},
|
Broadcast: &config.Broadcast{},
|
||||||
WebRTC: &config.WebRTC{},
|
WebRTC: &config.WebRTC{},
|
||||||
WebSocket: &config.WebSocket{},
|
WebSocket: &config.WebSocket{},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,14 +99,18 @@ func (i *Version) Details() string {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
type Neko struct {
|
type Configs struct {
|
||||||
Version *Version
|
|
||||||
Root *config.Root
|
Root *config.Root
|
||||||
Remote *config.Remote
|
Remote *config.Remote
|
||||||
Broadcast *config.Broadcast
|
Broadcast *config.Broadcast
|
||||||
Server *config.Server
|
Server *config.Server
|
||||||
WebRTC *config.WebRTC
|
WebRTC *config.WebRTC
|
||||||
WebSocket *config.WebSocket
|
WebSocket *config.WebSocket
|
||||||
|
}
|
||||||
|
|
||||||
|
type Neko struct {
|
||||||
|
Version *Version
|
||||||
|
Configs *Configs
|
||||||
|
|
||||||
logger zerolog.Logger
|
logger zerolog.Logger
|
||||||
server *http.Server
|
server *http.Server
|
||||||
@ -120,34 +126,45 @@ func (neko *Neko) Preflight() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (neko *Neko) Start() {
|
func (neko *Neko) Start() {
|
||||||
broadcastManager := broadcast.New(neko.Remote, neko.Broadcast)
|
neko.broadcastManager = broadcast.New(
|
||||||
|
neko.Configs.Remote,
|
||||||
remoteManager := remote.New(neko.Remote, broadcastManager)
|
neko.Configs.Broadcast,
|
||||||
remoteManager.Start()
|
|
||||||
|
|
||||||
sessionManager := session.New(remoteManager)
|
|
||||||
|
|
||||||
webRTCManager := webrtc.New(sessionManager, remoteManager, neko.WebRTC)
|
|
||||||
webRTCManager.Start()
|
|
||||||
|
|
||||||
webSocketHandler := websocket.New(sessionManager, remoteManager, broadcastManager, webRTCManager, neko.WebSocket)
|
|
||||||
webSocketHandler.Start()
|
|
||||||
|
|
||||||
server := http.New(
|
|
||||||
sessionManager,
|
|
||||||
remoteManager,
|
|
||||||
broadcastManager,
|
|
||||||
webSocketHandler,
|
|
||||||
neko.Server,
|
|
||||||
)
|
)
|
||||||
server.Start()
|
|
||||||
|
|
||||||
neko.sessionManager = sessionManager
|
neko.remoteManager = remote.New(
|
||||||
neko.remoteManager = remoteManager
|
neko.Configs.Remote,
|
||||||
neko.broadcastManager = broadcastManager
|
neko.broadcastManager,
|
||||||
neko.webRTCManager = webRTCManager
|
)
|
||||||
neko.webSocketHandler = webSocketHandler
|
neko.remoteManager.Start()
|
||||||
neko.server = server
|
|
||||||
|
neko.sessionManager = session.New(
|
||||||
|
neko.remoteManager,
|
||||||
|
)
|
||||||
|
|
||||||
|
neko.webRTCManager = webrtc.New(
|
||||||
|
neko.sessionManager,
|
||||||
|
neko.remoteManager,
|
||||||
|
neko.Configs.WebRTC,
|
||||||
|
)
|
||||||
|
neko.webRTCManager.Start()
|
||||||
|
|
||||||
|
neko.webSocketHandler = websocket.New(
|
||||||
|
neko.sessionManager,
|
||||||
|
neko.remoteManager,
|
||||||
|
neko.broadcastManager,
|
||||||
|
neko.webRTCManager,
|
||||||
|
neko.Configs.WebSocket,
|
||||||
|
)
|
||||||
|
neko.webSocketHandler.Start()
|
||||||
|
|
||||||
|
neko.server = http.New(
|
||||||
|
neko.sessionManager,
|
||||||
|
neko.remoteManager,
|
||||||
|
neko.broadcastManager,
|
||||||
|
neko.webSocketHandler,
|
||||||
|
neko.Configs.Server,
|
||||||
|
)
|
||||||
|
neko.server.Start()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (neko *Neko) Shutdown() {
|
func (neko *Neko) Shutdown() {
|
||||||
|
Loading…
Reference in New Issue
Block a user