zegsocket

package
v0.0.0-...-39be87d Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2022 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var PoolIDs []string

Functions

func Contains

func Contains(s []string, str string) bool

func CycleClients

func CycleClients(p *Pool, m Message)

func Gamesocket

func Gamesocket(c echo.Context) error

func GetClientID

func GetClientID() string

func Registering

func Registering(c *Client, p *Pool)

func Remove

func Remove(s []string, i int) []string

func Unregistering

func Unregistering(c *Client, p *Pool)

func Upgrade

func Upgrade(w http.ResponseWriter, r *http.Request) (*websocket.Conn, error)

func Writer

func Writer(conn *websocket.Conn)

Types

type Client

type Client struct {
	Conn      *websocket.Conn
	Pool      *Pool
	ClientID  string   `json:"clientid,omitempty"`
	PoolID    string   `json:"poolid,omitempty"`
	Color     string   `json:"color,omitempty"`
	Points    int      `json:"points,omitempty"`
	Left      float32  `json:"left,omitempty"`
	Top       float32  `json:"top,omitempty"`
	Right     float32  `json:"right,omitempty"`
	Bottom    float32  `json:"bottom,omitempty"`
	ClientIDs []string `json:"clientids,omitempty"`
	Count     int      `json:"count,omitempty"`
}

func (*Client) Read

func (c *Client) Read()

type Data

type Data struct {
	Clientid  string   `json:"clientid,omitempty"`
	PoolID    string   `json:"poolid,omitempty"`
	Color     string   `json:"color,omitempty"`
	Points    int      `json:"points,omitempty"`
	Left      float32  `json:"left,omitempty"`
	Top       float32  `json:"top,omitempty"`
	Right     float32  `json:"right,omitempty"`
	Bottom    float32  `json:"bottom,omitempty"`
	ClientIDs []string `json:"clientids,omitempty"`
	CD        []Data   `json:"cd,omitempty"`
	Count     int      `json:"count,omitempty"`
}

type Message

type Message struct {
	Type       int    `json:"type"`
	Body       string `json:"body"`
	Clientdata string `json:"client"`
	ClientID   string `json:"clientid"`
}

type Pool

type Pool struct {
	Register   chan *Client
	Unregister chan *Client
	Clients    map[*Client]bool
	Broadcast  chan Message
	PoolID     string
	ClientID   string
}

func NewPool

func NewPool() *Pool

func (*Pool) Start

func (pool *Pool) Start()

Jump to

Keyboard shortcuts

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