Improve event emitter/subscription abilities

This commit is contained in:
Dane Everitt
2020-01-18 14:04:26 -08:00
parent c6fcd8cabb
commit 99a11f81c3
8 changed files with 131 additions and 103 deletions

View File

@@ -1,9 +1,13 @@
package server
import "io"
import (
"fmt"
"github.com/mitchellh/colorstring"
"io"
)
type Console struct {
Server *Server
Server *Server
HandlerFunc *func(string)
}
@@ -18,4 +22,13 @@ func (c Console) Write(b []byte) (int, error) {
}
return len(b), nil
}
}
// Sends output to the server console formatted to appear correctly as being sent
// from Wings.
func (s *Server) PublishConsoleOutputFromDaemon(data string) {
s.Events().Publish(
ConsoleOutputEvent,
colorstring.Color(fmt.Sprintf("[yellow][bold][Pterodactyl Daemon]:[default] %s", data)),
)
}