Documentation ¶
Overview ¶
Package browserchannel provides a server-side browser channel implementation. See http://goo.gl/F287G for the client-side API.
Index ¶
Constants ¶
const ( // The path for the channel connection. DefaultBindPath = "bind" // The path for the test connection. DefaultTestPath = "test" )
const SupportedProcolVersion = 8
The browser channel protocol version implemented by this library.
Variables ¶
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.
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) SetCrossDomainPrefix ¶
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.