ssredis

package
v0.0.0-...-508e9f6 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2018 License: MIT Imports: 7 Imported by: 1

Documentation

Overview

Package ssredis provides a ss.MultihomeBackend interface that uses Redis for synchronizing broadcasts and roomcasts between multiple Sacrificial Socket instances.

Index

Constants

View Source
const (
	//the default redis.PubSub channel that will be subscribed to
	DefServerGroup = "ss-rmhb-group-default"
)

Variables

View Source
var (
	ErrBadDataType = errors.New("bad data type")
	ErrNoEventName = errors.New("no event name")
)

Functions

This section is empty.

Types

type Options

type Options struct {

	//ServerName is a unique name for the ss.MultihomeBackend instance.
	//This name must be unique per backend instance or the backend
	//will not broadcast and roomcast properly.
	//
	//Leave this name blank to auto generate a unique name.
	ServerName string

	//ServerGroup is the server pool name that this instance's broadcasts
	//and roomcasts will be published to. This can be used to break up
	//ss.MultihomeBackend instances into separate domains.
	//
	//Leave this empty to use the default group "ss-rmhb-group-default"
	ServerGroup string
}

type RMHB

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

RMHB implements the ss.MultihomeBackend interface and uses Redis to syncronize between multiple machines running ss.SocketServer

func NewBackend

func NewBackend(rOpts *redis.Options, ssrOpts *Options) (*RMHB, error)

NewBackend creates a new *RMHB specified by redis Options and ssredis Options

func (*RMHB) BroadcastFromBackend

func (r *RMHB) BroadcastFromBackend(bc chan<- *ss.BroadcastMsg)

BroadcastFromBackend will receive broadcast messages from redis and propogate them to the neccessary sockets

func (*RMHB) BroadcastToBackend

func (r *RMHB) BroadcastToBackend(b *ss.BroadcastMsg)

BroadcastToBackend will publish a broadcast message to the redis backend

func (*RMHB) Init

func (r *RMHB) Init()

Init is just here to satisfy the ss.MultihomeBackend interface.

func (*RMHB) RoomcastFromBackend

func (r *RMHB) RoomcastFromBackend(rc chan<- *ss.RoomMsg)

RoomcastFromBackend will receive roomcast messages from redis and propogate them to the neccessary sockets

func (*RMHB) RoomcastToBackend

func (r *RMHB) RoomcastToBackend(rm *ss.RoomMsg)

RoomcastToBackend will publish a roomcast message to the redis backend

func (*RMHB) Shutdown

func (r *RMHB) Shutdown()

Shutdown closes the subscribed redis channel, then the redis connection.

Jump to

Keyboard shortcuts

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