ws

package
v0.0.0-...-0ce7609 Latest Latest
Warning

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

Go to latest
Published: May 21, 2024 License: Unlicense Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	WsReadBufferSize  = 1024
	WsWriteBufferSize = 1024
	WsTimeoutSeconds  = 10
	ChannelSize       = 255
)

Functions

func GetWordDefinition

func GetWordDefinition(word string) string

GetWordDefinition returns the word definition from the Free Dictionary API

func SanitizeDefinition

func SanitizeDefinition(word, definition string) string

SanitizeDefinition replaces occurrences of the word in the definition with asterisks

func ShuffleWord

func ShuffleWord(word string) string

Types

type AnswerMessage

type AnswerMessage struct {
	Answer  string `json:"answer"`
	Command string `json:"command"`
}

type Client

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

func (*Client) GameSession

func (c *Client) GameSession()

GameSession handles the business logic for a connected client

func (*Client) ScoreUp

func (c *Client) ScoreUp()

type Def

type Def struct {
	Definition string `json:"definition"`
}

type Definition

type Definition struct {
	Meanings []Meaning `json:"meanings"`
}

type HintMessage

type HintMessage struct {
	Hint string `json:"hint"`
}

type Hub

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

func NewHub

func NewHub(db *gorm.DB) *Hub

func (*Hub) Heartbeat

func (h *Hub) Heartbeat()

This methods checks heartbeats of every connection and closes connections that do not answer ping messages

func (*Hub) WsHandler

func (h *Hub) WsHandler(c *gin.Context)

HTTP Handler for /ws endpoint

type Meaning

type Meaning struct {
	Definitions []Def `json:"definitions"`
}

type NickMessage

type NickMessage struct {
	Nick string `json:"nickname"`
}

type ScoreMessage

type ScoreMessage struct {
	Nick  string `json:"nick"`
	Score int    `json:"score"`
}

type SuccessMessage

type SuccessMessage struct {
	Success bool `json:"success"`
}

type WordmashMessage

type WordmashMessage struct {
	Wordmash string `json:"wordmash"`
}

Jump to

Keyboard shortcuts

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