Support websocket event to send server stats; ref pterodactyl/panel#2414

This commit is contained in:
Dane Everitt 2020-09-27 09:46:00 -07:00
parent 3655b172f3
commit a0fa5a94b6
No known key found for this signature in database
GPG Key ID: EEA66103B3D71F53
2 changed files with 11 additions and 0 deletions

View File

@ -8,6 +8,7 @@ const (
SetStateEvent = "set state" SetStateEvent = "set state"
SendServerLogsEvent = "send logs" SendServerLogsEvent = "send logs"
SendCommandEvent = "send command" SendCommandEvent = "send command"
SendStatsEvent = "send stats"
ErrorEvent = "daemon error" ErrorEvent = "daemon error"
JwtErrorEvent = "jwt error" JwtErrorEvent = "jwt error"
) )

View File

@ -360,6 +360,16 @@ func (h *Handler) HandleInbound(m Message) error {
}) })
} }
return nil
}
case SendStatsEvent:
{
b, _ := json.Marshal(h.server.Proc())
h.SendJson(&Message{
Event: server.StatsEvent,
Args: []string{string(b)},
})
return nil return nil
} }
case SendCommandEvent: case SendCommandEvent: