mirror of
https://github.com/aljazceru/khatru.git
synced 2026-02-21 04:34:22 +01:00
a function to send an event directly to a specific connection.
This commit is contained in:
@@ -140,7 +140,7 @@ func (rl *Relay) notifyListeners(event *nostr.Event) {
|
||||
return
|
||||
}
|
||||
}
|
||||
listener.ws.WriteJSON(nostr.EventEnvelope{SubscriptionID: &listener.id, Event: *event})
|
||||
listener.ws.SendEvent(listener.id, *event)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"sync"
|
||||
|
||||
"github.com/fasthttp/websocket"
|
||||
"github.com/nbd-wtf/go-nostr"
|
||||
)
|
||||
|
||||
type WebSocket struct {
|
||||
@@ -33,3 +34,10 @@ func (ws *WebSocket) WriteMessage(t int, b []byte) error {
|
||||
defer ws.mutex.Unlock()
|
||||
return ws.conn.WriteMessage(t, b)
|
||||
}
|
||||
|
||||
func (ws *WebSocket) SendEvent(subscriptionId string, event nostr.Event) error {
|
||||
return ws.WriteJSON(nostr.EventEnvelope{
|
||||
SubscriptionID: &subscriptionId,
|
||||
Event: event,
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user