khatru: list clients and client details.

This commit is contained in:
fiatjaf
2026-04-16 11:56:33 -03:00
parent 31473172a9
commit f50b7b0f8d
2 changed files with 96 additions and 0 deletions
+10
View File
@@ -2,9 +2,12 @@ package khatru
import (
"context"
"encoding/base64"
"encoding/binary"
"fmt"
"net/http"
"sync"
"unsafe"
"fiatjaf.com/nostr"
"github.com/fasthttp/websocket"
@@ -31,6 +34,13 @@ type WebSocket struct {
negentropySessions *xsync.MapOf[string, *NegentropySession]
}
func (ws *WebSocket) GetID() string {
ptr := uintptr(unsafe.Pointer(ws))
var id [8]byte
binary.LittleEndian.PutUint64(id[:], uint64(ptr))
return base64.RawURLEncoding.EncodeToString(id[:])
}
func (ws *WebSocket) WriteJSON(any any) error {
if ws == nil {
return fmt.Errorf("connection doesn't exist")