Documentation ¶
Overview ¶
Package relayr provides high level functionality for real-time web communication. It allows communication between front-end clients and back-end servers via easy-to-use constructs.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ClientScriptFunc func([]byte) []byte
ClientScriptFunc is a callback for altering the client side generated Javascript. This can be used to minify/alter the generated client-side RelayR library before it gets to the browser.
Functions ¶
func DisableScriptCache ¶ added in v0.2.1
func DisableScriptCache()
DisableScriptCache forces the RelayR client-side script to be regenerated on each request, rather than serving it from an internal cache.
Types ¶
type ClientOperations ¶ added in v0.2.0
type ClientOperations struct {
// contains filtered or unexported fields
}
ClientOperations provides helper methods for interacting with Clients connected to a Relay.
func (*ClientOperations) All ¶ added in v0.2.0
func (c *ClientOperations) All(fn string, args ...interface{})
All invokes a client side method on all clients for the given relay.
func (*ClientOperations) Others ¶ added in v0.2.0
func (c *ClientOperations) Others(fn string, args ...interface{})
Others invokes a client side method on all clients except the one who calls it.
type Exchange ¶
type Exchange struct {
// contains filtered or unexported fields
}
Exchange represents a hub where clients exchange information via Relays. Relays registered with the Exchange expose methods that can be invoked by clients.
func (*Exchange) RegisterRelay ¶
func (e *Exchange) RegisterRelay(x interface{})
RegisterRelay registers a struct as a Relay with the Exchange. This allows clients to invoke server methods on a Relay and allows the Exchange to invoke methods on a Relay on the server side.
type GroupOperations ¶ added in v0.2.0
type GroupOperations struct {
// contains filtered or unexported fields
}
GroupOperations provides helper methods for communicating with clients in groups. Clients must be added to a group to be considered a member of a group.
func (*GroupOperations) Add ¶ added in v0.2.0
func (g *GroupOperations) Add(connectionID string)
Add adds a client to a group via its ConnectionID. It is a member of the group for the remainder of its connection. At that point, the client must re-negotiate its place within the group to be considered a member of it.
func (*GroupOperations) Call ¶ added in v0.2.0
func (g *GroupOperations) Call(fn string, args ...interface{})
Call invokes a client-side method across a Group of clients, passing args to them.
func (*GroupOperations) Remove ¶ added in v0.2.0
func (g *GroupOperations) Remove(connectionID string)
Remove removes a client from a group via its ConnectionID.
type Relay ¶
type Relay struct { Name string // The name of the relay it is associated with ConnectionID string // The connectionID of the client that this Relay interacts with Clients *ClientOperations // An abstraction over clients currently connected to this Relay // contains filtered or unexported fields }
Relay encapsulates a connection with a client during an interaction with the server. It provides methods for interacting with clients and groups.
func (*Relay) Call ¶ added in v0.2.0
Call will execute a function on another server-side Relay, passing along the details of the currently connected client.
func (*Relay) Groups ¶ added in v0.2.0
func (r *Relay) Groups(group string) *GroupOperations
Groups returns a GroupOperations object, which offers helper methods for communicating with and grouping clients.