browserchannel

package
v0.0.0-...-c33774f Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2013 License: MIT Imports: 16 Imported by: 2

Documentation

Overview

Package browserchannel provides a server-side browser channel implementation. See http://goo.gl/F287G for the client-side API.

Index

Constants

View Source
const (
	// The path for the channel connection.
	DefaultBindPath = "bind"
	// The path for the test connection.
	DefaultTestPath = "test"
)
View Source
const SupportedProcolVersion = 8

The browser channel protocol version implemented by this library.

Variables

View Source
var (
	ErrClosed = errors.New("channel closed")
)

Functions

This section is empty.

Types

type Array

type Array []interface{}

Type of the data transmitted from the server to the client. The values stored in the array will be serialized to JSON.

type Channel

type Channel struct {
	// The client specific version string.
	Version string
	// The channel session id.
	Sid SessionId
	// contains filtered or unexported fields
}

func (*Channel) Close

func (c *Channel) Close()

Close the channel from the server side. Outgoing arrays will be delivered to the client before shutting down the channel permanently. SendArray calls will return an error after the channel has been closed.

func (*Channel) Maps

func (c *Channel) Maps() <-chan Map

Returns the map channel on which maps received from the client will be sent. The map channel will be closed when the browser channel to this client is closed.

func (*Channel) SendArray

func (c *Channel) SendArray(array Array) (err error)

Sends an array on the channel. Will return an error if the channel isn't ready, i.e. initializing or closed.

type ChannelHandler

type ChannelHandler func(*Channel)

The browser channel HTTP handler will invoke its ChannelHandler in a goroutine for each new browser channel connection established.

type Handler

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

The browser channel http.Handler.

func NewHandler

func NewHandler(chanHandler ChannelHandler) (h *Handler)

Creates a new browser channel HTTP handler. The last path segment of the URL is used to distinguish bind and test connections.

func (*Handler) ServeHTTP

func (h *Handler) ServeHTTP(rw http.ResponseWriter, req *http.Request)

func (*Handler) SetCrossDomainPrefix

func (h *Handler) SetCrossDomainPrefix(domain string, prefixes []string)

Sets the cross domain information for this browser channel. The origin is used as the Access-Control-Allow-Origin header value and should respect the format specified by http://www.w3.org/TR/cors/. The prefixes are used to set the hostPrefix parameter on the client side. The prefix assigned to each browser channel session is chosen randomly from the array of prefixes.

type Map

type Map map[string]string

Type of the data transmitted from the client to the server.

type SessionId

type SessionId [bytesPerSessionId]byte

func (SessionId) String

func (s SessionId) String() string

Gets the hexadecimal representation of the SessionId.

Jump to

Keyboard shortcuts

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