add reconnect to websocket, add get world json object
This commit is contained in:
@@ -6,13 +6,24 @@ import (
|
||||
)
|
||||
|
||||
type WsSessionMsg struct {
|
||||
SessionId string `json:"sessionId"`
|
||||
UserId *string `json:"userId,omitempty"`
|
||||
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")
|
||||
tr.Logger.Info("Session msg", "userid", msg.UserId)
|
||||
if msg.UserId == "" {
|
||||
err := tr.LogInToWorld()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
tr.Logger.Info("World is started. Succesfully logged into world")
|
||||
close(tr.ReadChan.Reconnect())
|
||||
return nil
|
||||
}
|
||||
// tr.Logger.Warn("World is started. Please, return to setup page to fully initialize database")
|
||||
// go msg.OnActiveWorld(tr)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -24,3 +35,15 @@ func (msg WsSessionMsg) Action(tr *transport.FoundryTransport, status *types.Fou
|
||||
go tr.FillDBWithFoundryData()
|
||||
return nil
|
||||
}
|
||||
|
||||
func (msg WsSessionMsg) OnActiveWorld(tr *transport.FoundryTransport) error {
|
||||
wsMsg := types.NewWsMessage("world", tr.CurrWsId)
|
||||
tr.CurrWsId++
|
||||
|
||||
answer, err := tr.HandleWebsocketRequest(wsMsg)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
tr.Logger.Info("World data", "answer", string(answer))
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user