khatru: list clients and client details.
This commit is contained in:
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user