websocket

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: May 7, 2020 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Upgrade

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

Upgrade ...

Types

type BroadcastNotification added in v0.3.2

type BroadcastNotification struct {
	Score  float64
	Msg    []byte
	Resend bool
}

BroadcastNotification ...

func (BroadcastNotification) GetMessage added in v0.3.2

func (bn BroadcastNotification) GetMessage() []byte

func (BroadcastNotification) GetScore added in v0.3.2

func (bn BroadcastNotification) GetScore() float64

func (BroadcastNotification) IsResend added in v0.3.2

func (bn BroadcastNotification) IsResend() bool

type Client

type Client struct {
	Conn  *websocket.Conn
	Pool  *Pool
	ID    *users.UserID
	Token string
	// contains filtered or unexported fields
}

Client ...

func (*Client) Read

func (c *Client) Read()

type Notification added in v0.3.2

type Notification interface {
	GetScore() float64
	GetMessage() []byte
	IsResend() bool
}

Notification

type Pool

type Pool struct {
	Register      chan *Client
	Unregister    chan *Client
	Login         chan *Client
	NotifyUser    chan UserNotification
	Broadcast     chan BroadcastNotification
	Clients       map[*Client]bool
	ClientMapping map[string]*Client
	Rclient       *redis.Client
	BufferSize    int64
}

Pool ...

func NewPool

func NewPool(size int64) *Pool

NewPool ...

func (*Pool) Start

func (pool *Pool) Start()

Start ...

type UserNotification added in v0.3.2

type UserNotification struct {
	ID     *users.UserID
	Score  float64
	Msg    []byte
	Resend bool
}

UserNotification ...

func (UserNotification) GetMessage added in v0.3.2

func (un UserNotification) GetMessage() []byte

func (UserNotification) GetScore added in v0.3.2

func (un UserNotification) GetScore() float64

func (UserNotification) IsResend added in v0.3.2

func (un UserNotification) IsResend() bool

Jump to

Keyboard shortcuts

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