Help us shape the future of Go! Take the 2026 Go Developer Survey

relayR

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2015 License: Apache-2.0 Imports: 12 Imported by: 0

README

RelayR

RelayR is a Go package that provides easy-to-use real time communication APIs for Go web applications.

Installation

IMPORTANT:

RelayR relies on the Gorilla WebSocket package for WebSocket support. Please head over to that repository, give it a star, and ``go getit into yourGOPATH`.

Also important: RelayR currently only supports WebSockets. Server Sent Events and Long Polling options are on the roadmap.

Installing RelayR

After you have installed the Gorilla WebSocket package, you can run the following:

go get -u https://github.com/simon-whitehead/relayR

Examples

The /examples directory contains three examples.

The first one is a simple Server -> Client timestamp push. The server will push the current time down to all connected clients every second.

It looks like this:

relayr-time-push

The second one is a replica of the famous SignalR sample, "High-Frequency Realtime with SignalR" where a shape can be dragged around a browser and broadcast to all clients.

It looks like this:

relayr-shape-move

The third one demonstrates Groups and membership. It allows clients to subscribe to groups and receive notifications that are pushed to groups they are subscribed to.

Project status

This is very much a work in progress - some might say, pre-alpha. The code is horrible .. but it works. I am opening it up to the world early for feedback and contributions (in any form).

Contributing

Please! Fork away .. improve it .. create a PR .. whatever you want to do. I am open to any and all help.

Licence

This code is released under the Apache 2.0 licence.

Documentation

Overview

Package relayR provides simple APIs for adding real-time communication to Go web applications.

Index

Constants

This section is empty.

Variables

View Source
var ClientScriptFunc func([]byte) []byte

Functions

func Handle

func Handle(route string, e *Exchange)

Handle specifies the route to server the RelayR client script from.

Types

type Exchange

type Exchange struct {
	Relays map[reflect.Type]Relay
	// contains filtered or unexported fields
}

Exchange is the root object required to interact with the RelayR package

func NewExchange

func NewExchange() *Exchange

NewExchange initializes and returns an *Exchange

func (*Exchange) RegisterRelay

func (e *Exchange) RegisterRelay(relay interface{})

RegisterRelay registers a struct with an Exchange. If the struct does not embed relayR.Relay, it will panic.

func (*Exchange) Relay

func (e *Exchange) Relay(v interface{}) relayOperations

Relay allows operations to be performed on a registered Relay

type Relay

type Relay struct {
	Name string // The name of the relay

	ConnectionID string // Unique identifier given to a connection

	Clients *clientOperations
	// contains filtered or unexported fields
}

Relay represents a type that the runtime is aware of

Directories

Path Synopsis
examples
group command
shape-move command
time-push command

Jump to

Keyboard shortcuts

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