ws

package
v0.0.0-...-f1dee3b Latest Latest
Warning

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

Go to latest
Published: May 9, 2019 License: MIT Imports: 8 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	WritePump()
	ReadPump()
	Send(message []byte)
	GetSend() chan []byte
	GetID() int32
	Close()
}

Client is equivalent to a user connection.

func NewClient

func NewClient(conn *websocket.Conn, hub Hub) Client

NewClient returns new client given hub

type Hub

type Hub interface {
	Run()
	UnRegister(c Client)
	Register(c *websocket.Conn) chan Client
	ReceiveMessage(b []byte)
	Broadcast(b []byte)
	BroadcastExclude(b []byte, id int32)
	BindGameMaster(g IGame)
	Send(clientID int32, b []byte)
}

Hub contains all client

func NewHub

func NewHub() Hub

type IGame

type IGame interface {
	ProcessInput(message []byte)
	RemovePlayerByClientID(clientID int32)
}

IGame is the interface Game master expose to Hub. If Hub want to call Game master, it needs to call from IGame

Jump to

Keyboard shortcuts

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