sockets

package
v0.0.0-...-8aa12d4 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2023 License: MPL-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidAction = fmt.Errorf("invalid API action")
View Source
var (
	Manager *websocket.Manager
)

Functions

func Broadcast

func Broadcast(msg []byte, ringID int) error

func CloseConnection

func CloseConnection(id string)

func ConstructMessage

func ConstructMessage(action Action, params []interface{}) ([]byte, error)

func Notify

func Notify(msg []byte, id string) (err error)

func NotifyCompetitorChange

func NotifyCompetitorChange(ringID int) error

func NotifyHeadJudge

func NotifyHeadJudge(msg []byte, ringID int) error

func WSServer

func WSServer(w http.ResponseWriter, r *http.Request, msgCB OnMessage)

Types

type Action

type Action int
const (
	// Client actions
	AdjustScore      Action = iota // adjust-score
	CalculateScore                 // calculate-score
	ChangeCompetitor               // change-competitor
	ChangeEvent                    // change-event
	FinalizeScore                  // finalize-score
	RegisterDisplay                // register-display
	RegisterJudge                  // register-judge
	StartTimer                     // start-timer
	StopTimer                      // stop-timer
	SubmitDeductions               // submit-deductions
	SubmitNandu                    // submit-nandu
	SubmitScore                    // submit-score

	// Server actions
	ClientInit       // init
	ListCompetitors  // list-competitors
	ListEvents       // list-events
	NotifyCompetitor // notify-competitor
	NotifyEvent      // notify-event
	NotifyFinalScore // notify-final-score
	Rescore          // rescore
	RingStatus       // ring-status
	RingUpdate       // ring-update
	Score            // score
	StartEvent       // start-event
	StopEvent        // stop-event
	LastDisplay      // last-display
	LiveDisplay      // live-display

	// Error
	InvalidAction // invalid
)

func ToAction

func ToAction(s string) (Action, error)

func (Action) String

func (i Action) String() string

type Connection

type Connection struct {
	ID string
	// contains filtered or unexported fields
}

func NewConnection

func NewConnection(ws *gorilla.Conn) *Connection

type Message

type Message struct {
	Timestamp int64         `json:"timestamp"`
	Client    string        `json:"client"`
	RingID    int           `json:"ring"`
	Action    string        `json:"action"`
	Params    []interface{} `json:"params"`
}

type OnMessage

type OnMessage func(*Connection, Message)

Jump to

Keyboard shortcuts

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