refactor foundry lib structure; add transport classes for db,http,websocket; add action interface instead of multiple function that accepts action classes; add changing foundry status on websocket responses
This commit is contained in:
26
internal/foundry/actions/session.go
Normal file
26
internal/foundry/actions/session.go
Normal file
@@ -0,0 +1,26 @@
|
||||
package actions
|
||||
|
||||
import (
|
||||
"gitea.local.lab/Lbenedar/foundry_helper_service/internal/foundry/transport"
|
||||
"gitea.local.lab/Lbenedar/foundry_helper_service/internal/foundry/types"
|
||||
)
|
||||
|
||||
type WsSessionMsg struct {
|
||||
SessionId string `json:"sessionId"`
|
||||
UserId *string `json:"userId,omitempty"`
|
||||
}
|
||||
|
||||
func (msg WsSessionMsg) Action(tr *transport.FoundryTransport, status *types.FoundryStatus) error {
|
||||
if status.IsActive {
|
||||
tr.Logger.Warn("World is started. Please, return to setup page to fully initialize database")
|
||||
return nil
|
||||
}
|
||||
|
||||
if tr.IsDbInit {
|
||||
return nil
|
||||
}
|
||||
tr.IsDbInit = true
|
||||
|
||||
go tr.FillDBWithFoundryData()
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user