event

package
v0.0.0-...-43a0c9e Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2015 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package event includes event related manipulations.

Index

Constants

View Source
const (
	// EvtCodeGOPATHNotFound indicates an event: not found $GOPATH env variable
	EvtCodeGOPATHNotFound = iota
	// EvtCodeGOROOTNotFound indicates an event: not found $GOROOT env variable
	EvtCodeGOROOTNotFound
	// EvtCodeGocodeNotFound indicates an event: not found gocode
	EvtCodeGocodeNotFound
	// EvtCodeIDEStubNotFound indicates an event: not found ide_stub
	EvtCodeIDEStubNotFound
	// EvtCodeServerInternalError indicates an event: server internal error
	EvtCodeServerInternalError
)

Variables

View Source
var EventQueue = make(chan *Event, maxQueueLength)

Global event queue.

Every event in this queue will be dispatched to each user event queue.

View Source
var UserEventQueues = queues{}

User event queues.

<sid, *UserEventQueue>

Functions

func Load

func Load()

Load initializes the event handling.

Types

type Event

type Event struct {
	Code int         `json:"code"` // event code
	Sid  string      `json:"sid"`  // wide session id related
	Data interface{} `json:"data"` // event data
}

Event represents an event.

type HandleFunc

type HandleFunc func(event *Event)

HandleFunc represents a handler function.

func (HandleFunc) Handle

func (fn HandleFunc) Handle(event *Event)

Default implementation of event handling.

type Handler

type Handler interface {
	Handle(event *Event)
}

Handler represents an event handler.

type UserEventQueue

type UserEventQueue struct {
	Sid      string      // wide session id related
	Queue    chan *Event // queue
	Handlers []Handler   // event handlers
}

UserEventQueue represents a user event queue.

func (*UserEventQueue) AddHandler

func (uq *UserEventQueue) AddHandler(handlers ...Handler)

AddHandler adds the specified handlers to user event queues.

Jump to

Keyboard shortcuts

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