MCPcopy Create free account
hub / github.com/CPChain/chain / Notify

Method Notify

api/rpc/subscription.go:90–103  ·  view source on GitHub ↗

Notify sends a notification to the client with the given data as payload. If an error occurs the RPC connection is closed and the error is returned.

(id ID, data interface{})

Source from the content-addressed store, hash-verified

88// Notify sends a notification to the client with the given data as payload.
89// If an error occurs the RPC connection is closed and the error is returned.
90func (n *Notifier) Notify(id ID, data interface{}) error {
91 n.subMu.RLock()
92 defer n.subMu.RUnlock()
93
94 sub, active := n.active[id]
95 if active {
96 notification := n.codec.CreateNotification(string(id), sub.namespace, data)
97 if err := n.codec.Write(notification); err != nil {
98 n.codec.Close()
99 return err
100 }
101 }
102 return nil
103}
104
105// Closed returns a channel that is closed when the RPC connection is closed.
106func (n *Notifier) Closed() <-chan interface{} {

Callers 5

handleInterruptFunction · 0.45
ImportChainFunction · 0.45
SomeSubscriptionMethod · 0.45
HangSubscriptionMethod · 0.45
PeerEventsMethod · 0.45

Calls 3

CreateNotificationMethod · 0.65
WriteMethod · 0.65
CloseMethod · 0.65

Tested by 2

SomeSubscriptionMethod · 0.36
HangSubscriptionMethod · 0.36