wsserver

package
v0.0.0-...-4c73ccb Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2024 License: Apache-2.0 Imports: 9 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	RemoteAddr string

	sync.Mutex
	// contains filtered or unexported fields
}

Client websocket client handler.

func (*Client) SendMessage

func (client *Client) SendMessage(messageType int, data []byte) (err error)

SendMessage sends message to ws client.

type ClientHandler

type ClientHandler interface {
	ClientConnected(client *Client)
	ProcessMessage(client *Client, messageType int, message []byte) (response []byte, err error)
	ClientDisconnected(client *Client)
}

ClientHandler provides interface to handle client.

type Server

type Server struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Server websocket server structure.

func New

func New(name, url, cert, key string, handler ClientHandler) (server *Server, err error)

New creates new Web socket server.

func (*Server) Close

func (server *Server) Close()

Close closes web socket server and all connections.

func (*Server) GetClients

func (server *Server) GetClients() (clients []*Client)

GetClients return client list.

Jump to

Keyboard shortcuts

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