Send the server logs when the websocket is connected to initially
This commit is contained in:
parent
93c71a6ab7
commit
2db705f697
|
@ -5,6 +5,7 @@ type EventListeners map[string][]EventListenerFunction
|
|||
type EventListenerFunction *func(string)
|
||||
|
||||
// Defines all of the possible output events for a server.
|
||||
// noinspection GoNameStartsWithPackageName
|
||||
const (
|
||||
ConsoleOutputEvent = "console output"
|
||||
StatusEvent = "status"
|
||||
|
|
|
@ -78,6 +78,9 @@ func (rt *Router) routeWebsocket(w http.ResponseWriter, r *http.Request, ps http
|
|||
defer s.RemoveListener(server.ConsoleOutputEvent, &handleOutput)
|
||||
|
||||
s.Emit(server.StatusEvent, s.State)
|
||||
if s.State != server.ProcessOfflineState {
|
||||
handler.HandleInbound(WebsocketMessage{inbound: true, Event: SendServerLogsEvent})
|
||||
}
|
||||
|
||||
for {
|
||||
j := WebsocketMessage{inbound: true}
|
||||
|
@ -99,6 +102,8 @@ func (rt *Router) routeWebsocket(w http.ResponseWriter, r *http.Request, ps http
|
|||
if err := handler.HandleInbound(j); err != nil {
|
||||
zap.S().Warnw("error handling inbound websocket request", zap.Error(err))
|
||||
break
|
||||
} else {
|
||||
zap.S().Debugw("handled event", zap.String("event", j.Event), zap.Strings("args", j.Args))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -143,7 +148,7 @@ func (wsh *WebsocketHandler) HandleInbound(m WebsocketMessage) error {
|
|||
}
|
||||
case SendServerLogsEvent:
|
||||
{
|
||||
logs, err := wsh.Server.Environment.Readlog(1024 * 5)
|
||||
logs, err := wsh.Server.Environment.Readlog(1024 * 16)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user