websockets

package
v0.0.0-...-776aec6 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2020 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Overview

Package websockets implements functionality related to the API websockets.

Index

Constants

View Source
const (
	TypeConnected                = "connected"
	TypeInvalidMessage           = "invalid_message_type"
	TypeUnexpectedError          = "unexpected_error"
	TypeNotFound                 = "not_found"
	TypeSubscribedToScores       = "subscribed_to_scores"
	TypeNewScore                 = "new_score"
	TypeSubscribedToMultiMatches = "subscribed_mp_complete_match"
	TypeNewMatch                 = "new_completed_match"
	TypeIdentified               = "identified"
	TypeRestrictedVisibilitySet  = "restricted_visibility_set"
	TypePong                     = "pong"
)

Server Message Types

View Source
const (
	TypeSubscribeScores         = "subscribe_scores"
	TypeSubscribeMultiMatches   = "subscribe_mp_complete_match"
	TypeIdentify                = "identify"
	TypeSetRestrictedVisibility = "set_restricted_visibility"
	TypePing                    = "ping"
)

Client Message Types

Variables

This section is empty.

Functions

func Identify

func Identify(c *conn, message incomingMessage)

Identify sets the identity of the user.

func SetRestrictedVisibility

func SetRestrictedVisibility(c *conn, message incomingMessage)

SetRestrictedVisibility sets whether the information of restricted users can be seen.

func Start

func Start(r *redis.Client, _db *sqlx.DB) error

Start begins websocket functionality

func SubscribeMultiMatches

func SubscribeMultiMatches(c *conn, message incomingMessage)

SubscribeMultiMatches subscribes to receiving information from completed games in multiplayer matches.

func SubscribeScores

func SubscribeScores(c *conn, message incomingMessage)

SubscribeScores subscribes a connection to score updates.

func WebsocketV1Entry

func WebsocketV1Entry(ctx *fasthttp.RequestCtx)

WebsocketV1Entry upgrades a connection to a websocket.

Types

type Message

type Message struct {
	Type string      `json:"type"`
	Data interface{} `json:"data,omitempty"`
}

Message is the wrapped information for a message sent to the client.

Jump to

Keyboard shortcuts

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