server

package
v0.0.0-...-9a70a3a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 21, 2016 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MessageWithId

type MessageWithId struct {
	Id       *[32]byte
	Envelope []byte
}

type Notifier

type Notifier struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

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) Notify

func (n *Notifier) Notify(uid *[32]byte, msg_id *[32]byte, envelope []byte)

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 CreateTestServer

func CreateTestServer(t *testing.T) (*Server, *[32]byte, string, func())

func StartServer

func StartServer(db *leveldb.DB, shutdown chan struct{}, pk *[32]byte, sk *[32]byte, listenAddr string) (*Server, error)

func (*Server) RunServer

func (server *Server) RunServer() error

func (*Server) StopServer

func (server *Server) StopServer()

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL