Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MessageWithId ¶
type Notifier ¶
Notifier implements a simple publish-subscribe pattern for delivering push notifications to connected users. When a user connects and requests push notifications, the goroutine handling the connection should call StartWaiting and select on the channel for notifications. When a new message is received, calling Notify will check whether the recipient is connected and propogate the push notification to its thread.
func (*Notifier) StartWaiting ¶
func (n *Notifier) StartWaiting(uid *[32]byte) chan *MessageWithId
func (*Notifier) StopWaitingSync ¶
func (n *Notifier) StopWaitingSync(uid *[32]byte, removeCh chan *MessageWithId)
StopWaitingSync blocks returns after closing removeCh. Calling StopWaitingSync while a notification is pending will wait for that notification to be handled. Calling StopWaitingSync from the thread that should be handling the notification will therefore result in a deadlock. When removeCh is not waiting, nothing is done (but the blocking considerations still apply).
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func StartServer ¶
func (*Server) StopServer ¶
func (server *Server) StopServer()