aboutsummaryrefslogtreecommitdiff
path: root/hotline
diff options
context:
space:
mode:
authorJeff Halter <868228+jhalter@users.noreply.github.com>2024-07-18 16:15:08 -0700
committerJeff Halter <868228+jhalter@users.noreply.github.com>2024-07-18 16:21:19 -0700
commitb6e3be945680d017874967ae72ef86ee4235dcc2 (patch)
tree1dfe96f69563021d83132d0c18452c0870f9d673 /hotline
parentfd740bc499ebc6d3a381479316f74cdc736d02de (diff)
Add initial HTTP API endpoints
Diffstat (limited to 'hotline')
-rw-r--r--hotline/server.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/hotline/server.go b/hotline/server.go
index 58a9209..cfdb6b3 100644
--- a/hotline/server.go
+++ b/hotline/server.go
@@ -13,6 +13,7 @@ import (
"log"
"log/slog"
"net"
+ "os"
"strings"
"sync"
"time"
@@ -586,3 +587,18 @@ func (s *Server) handleFileTransfer(ctx context.Context, rwc io.ReadWriter) erro
}
return nil
}
+
+func (s *Server) SendAll(t TranType, fields ...Field) {
+ for _, c := range s.ClientMgr.List() {
+ s.outbox <- NewTransaction(t, c.ID, fields...)
+ }
+}
+
+func (s *Server) Shutdown(msg []byte) {
+ s.Logger.Info("Shutdown signal received")
+ s.SendAll(TranDisconnectMsg, NewField(FieldData, msg))
+
+ time.Sleep(3 * time.Second)
+
+ os.Exit(0)
+}