engineio

package module
v0.0.0-...-22d7027 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2013 License: MIT Imports: 14 Imported by: 0

README

engineio

Installing

Install Go 1, either from source or with a prepackaged binary. Then,

$ go get github.com/massiveart/engineio

Transports

  • polling: XHR/JSONP polling transport.
  • websocket: WebSocket transport.

Usage

A example can be found in the "example" subdirectory.

Documentation

Index

Constants

View Source
const DefaultEngineioPath = "/engine.io/"

Variables

View Source
var (
	ErrUnknownSession = errors.New("unknown session id")
	ErrQueueFull      = errors.New("queue limit reached")
	ErrNotConnected   = errors.New("not connected")
)
View Source
var DefaultConfig = &Config{
	QueueLength:  10,
	PingInterval: 25000,
	PingTimeout:  60000,
	Upgrades:     []string{"websocket"},
}

Functions

This section is empty.

Types

type AuthFunc

type AuthFunc func(*http.Request) bool

type Config

type Config struct {
	// Maximum amount of messages to store for a connection. If a
	// connection has QueueLength amount of undelivered messages,
	// the following writes will return ErrQueueFull error.
	QueueLength int

	// The size of the read buffer in bytes.
	ReadBufferSize int

	// Ping/Ping interval in milliseconds.
	PingInterval int64

	// Ping timeout in milliseconds.
	PingTimeout int64

	// Upgrades to use. (Only websocket supported).
	Upgrades []string
}

type Connection

type Connection interface {
	io.WriteCloser
	ID() string
	// contains filtered or unexported methods
}

type EngineIO

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

EngineIO handles transport abstraction and provide the user a handfull of callbacks to observe different events.

func NewEngineIO

func NewEngineIO(config *Config) *EngineIO

NewEngineIO allocates and returns a new EngineIO. If config is nil, the DefaultConfig is used.

func (EngineIO) Close

func (e EngineIO) Close() error

Close closes the engineio server and all it's connections.

func (*EngineIO) CloseFunc

func (e *EngineIO) CloseFunc(fn func(Connection))

CloseFunc sets fn to be invoked when a session is considered to be lost. It passes the established connection as an argument to the callback. After disconnection the connection is considered to be destroyed, and it should not be used anymore.

func (*EngineIO) ConnectionFunc

func (e *EngineIO) ConnectionFunc(fn func(Connection))

ConnectionFunc sets fn to be invoked when a new connection is established. It passes the established connection as an argument to the callback.

func (*EngineIO) Handler

func (e *EngineIO) Handler(w http.ResponseWriter, req *http.Request, fn AuthFunc)

func (*EngineIO) MessageFunc

func (e *EngineIO) MessageFunc(fn func(Connection, []byte) error)

MessageFunc sets fn to be invoked when a message arrives. It passes the established connection along with the received message datai as arguments to the callback.

Jump to

Keyboard shortcuts

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