diff options
| author | historia <[not public]> | 2026-06-11 04:46:27 -0400 |
|---|---|---|
| committer | historia <[not public]> | 2026-06-11 08:58:37 +0000 |
| commit | 1b9e2da3b3c438d8dc53d3489725dd5ba0022777 (patch) | |
| tree | 62264f24420bf4cfaa734942c65cc8dd45ba3d3b /internal/net/wsconn.go | |
| parent | 06c02a697e5daf8832a462de5970dd4c0e13a02c (diff) | |
| download | thehouseoficarus-1b9e2da3b3c438d8dc53d3489725dd5ba0022777.tar.gz | |
feat: web client, get/drop updates and fixes
Diffstat (limited to 'internal/net/wsconn.go')
| -rw-r--r-- | internal/net/wsconn.go | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/internal/net/wsconn.go b/internal/net/wsconn.go new file mode 100644 index 0000000..d6f45dc --- /dev/null +++ b/internal/net/wsconn.go @@ -0,0 +1,34 @@ +package net + +import ( + "github.com/gorilla/websocket" +) + +type wsConn struct { + conn *websocket.Conn +} + +func newWSConn(conn *websocket.Conn) *wsConn { + return &wsConn{conn: conn} +} + +func (w *wsConn) ReadMessage() (string, error) { + _, msg, err := w.conn.ReadMessage() + return string(msg), err +} + +func (w *wsConn) Write(b []byte) (int, error) { + err := w.conn.WriteMessage(websocket.TextMessage, b) + return len(b), err +} + +func (w *wsConn) Close() error { + return w.conn.Close() +} + +func (w *wsConn) SetEcho(on bool) error { + if on { + return w.conn.WriteMessage(websocket.TextMessage, []byte("\x1b]10;0\x07")) + } + return w.conn.WriteMessage(websocket.TextMessage, []byte("\x1b]10;1\x07")) +} |
