CreateSubscription returns a new subscription that is coupled to the RPC connection. By default subscriptions are inactive and notifications are dropped until the subscription is marked as active. This is done by the RPC server after the subscription ID is send to the client.
()
| 78 | // are dropped until the subscription is marked as active. This is done |
| 79 | // by the RPC server after the subscription ID is send to the client. |
| 80 | func (n *Notifier) CreateSubscription() *Subscription { |
| 81 | s := &Subscription{ID: NewID(), err: make(chan error)} |
| 82 | n.subMu.Lock() |
| 83 | n.inactive[s.ID] = s |
| 84 | n.subMu.Unlock() |
| 85 | return s |
| 86 | } |
| 87 | |
| 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. |