emitter

package
v2.0.73+incompatible Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2017 License: AGPL-3.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RequestKeygen   = 548658350
	RequestPresence = 3869262148
)
View Source
const (
	QueryType          = 1
	QueryActualKey     = 2 // As opposed to 'emitter/'
	QueryTargetChannel = 3
)

Variables

View Source
var (
	ErrBadRequest      = &EventError{code: 400, msg: "The request was invalid or cannot be otherwise served."}
	ErrUnauthorized    = &EventError{code: 401, msg: "The security key provided is not authorized to perform this operation."}
	ErrPaymentRequired = &EventError{code: 402, msg: "The request can not be served, as the payment is required to proceed."}
	ErrForbidden       = &EventError{code: 403, msg: "The request is understood, but it has been refused or access is not allowed."}
	ErrNotFound        = &EventError{code: 404, msg: "The resource requested does not exist."}
	ErrServerError     = &EventError{code: 500, msg: "An unexpected condition was encountered and no more specific message is suitable."}
	ErrNotImplemented  = &EventError{code: 501, msg: "The server either does not recognize the request method, or it lacks the ability to fulfill the request."}
)

Represents a set of errors used in the handlers.

Functions

func ProcessKeyGen

func ProcessKeyGen(channel *security.Channel) bool

func TryProcessAPIRequest

func TryProcessAPIRequest(channel *security.Channel) bool

TryProcessAPIRequest attempts to generate the key and returns the result.

Types

type Conn

type Conn struct {
	// contains filtered or unexported fields
}

Conn represents an incoming connection.

func (*Conn) Close

func (c *Conn) Close() error

Close terminates the connection.

func (*Conn) Process

func (c *Conn) Process()

Process processes the messages.

func (*Conn) Subscribe

func (c *Conn) Subscribe(contract int32, channel *security.Channel)

Subscribe subscribes to a particular channel.

func (*Conn) Unsubscribe

func (c *Conn) Unsubscribe(ssid Ssid)

Unsubscribe unsubscribes this client from a particular channel.

type EventError

type EventError struct {
	// contains filtered or unexported fields
}

EventError represents an event code which provides a more de.

func (*EventError) Error

func (e *EventError) Error() string

Error implements error interface.

type Service

type Service struct {
	Closing chan bool         // The channel for closing signal.
	Cipher  *security.Cipher  // The cipher to use for decoding and encoding keys.
	License *security.License // The licence for this emitter server.
	Config  *config.Config    // The configuration for the service.
	// contains filtered or unexported fields
}

Service represents the main structure.

func NewService

func NewService(cfg *config.Config) (s *Service, err error)

NewService creates a new service.

func (*Service) Broadcast

func (s *Service) Broadcast(name string, payload []byte, coalesce bool) error

Broadcast is used to broadcast a custom user event with a given name and payload. The events must be fairly small, and if the size limit is exceeded and error will be returned. If coalesce is enabled, nodes are allowed to coalesce this event.

func (*Service) Join

func (s *Service) Join(peers ...string) error

Join attempts to join a set of existing peers.

func (*Service) Listen

func (s *Service) Listen()

Listen starts the service.

func (*Service) OnSignal

func (s *Service) OnSignal(sig os.Signal)

OnSignal will be called when a OS-level signal is received.

type Ssid

type Ssid []uint32

Ssid represents a subscription ID which contains a contract and a list of hashes for various parts of the channel.

func NewSsid

func NewSsid(contract int32, c *security.Channel) Ssid

NewSsid creates a new Ssid.

func (Ssid) Contract

func (s Ssid) Contract() int32

Contract gets the contract part from Ssid.

func (Ssid) GetHashCode

func (s Ssid) GetHashCode() uint32

GetHashCode combines the ssid into a single hash.

type Subscriber

type Subscriber interface{}

Subscriber is a value associated with a subscription.

type Subscribers

type Subscribers []Subscriber

Subscribers represents a subscriber set which can contain only unique values.

func (*Subscribers) AddUnique

func (s *Subscribers) AddUnique(value Subscriber)

AddUnique adds a subscriber to the set.

func (*Subscribers) Contains

func (s *Subscribers) Contains(value Subscriber) bool

Contains checks whether a subscriber is in the set.

type Subscription

type Subscription struct {
	Ssid       Ssid       // Gets or sets the SSID (parsed channel) for this subscription.
	Channel    string     // Gets or sets the channel for this subscription.
	Subscriber Subscriber // Gets or sets the subscriber for this subscription.
}

Subscription represents a topic subscription.

type SubscriptionTrie

type SubscriptionTrie struct {
	// contains filtered or unexported fields
}

SubscriptionTrie represents an efficient collection of subscriptions with lookup capability.

func NewSubscriptionTrie

func NewSubscriptionTrie() *SubscriptionTrie

NewSubscriptionTrie creates a new matcher for the subscriptions.

func (*SubscriptionTrie) Lookup

func (c *SubscriptionTrie) Lookup(query Ssid) Subscribers

Lookup returns the Subscribers for the given topic.

func (*SubscriptionTrie) Subscribe

func (c *SubscriptionTrie) Subscribe(ssid Ssid, channel string, sub Subscriber) (*Subscription, error)

Subscribe adds the Subscriber to the topic and returns a Subscription.

func (*SubscriptionTrie) Unsubscribe

func (c *SubscriptionTrie) Unsubscribe(sub *Subscription)

Unsubscribe removes the Subscription.

Jump to

Keyboard shortcuts

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