websocketserver

package module
v0.0.0-...-f85c248 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2019 License: MIT Imports: 5 Imported by: 0

README

WebSocketServer

Documentation

Overview

@Time : 2019-07-12 12:38 @Author : zr

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Center

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

Center maintains the set of active Clients and broadcasts messages to the Clients.

func NewCenter

func NewCenter(msgHandler func(ClientInterface, []byte)) *Center

func (*Center) AddClient

func (c *Center) AddClient(client ClientInterface, w http.ResponseWriter, r *http.Request) error

serveWs handles websocket requests from the peer.

func (*Center) Clients

func (c *Center) Clients() Clients

func (*Center) Run

func (c *Center) Run()

type Client

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

Client is a middleman between the websocket connection and the center.

func (Client) Delete

func (c Client) Delete()

func (Client) GetId

func (c Client) GetId() uint64

func (*Client) Send

func (c *Client) Send(message []byte)

type ClientInterface

type ClientInterface interface {
	GetId() uint64
	Delete()
	// contains filtered or unexported methods
}

type Clients

type Clients map[uint64]ClientInterface

type MsgHandler

type MsgHandler func(ClientInterface, []byte)

Jump to

Keyboard shortcuts

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