server

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

func NewClient

func NewClient(socket *websocket.Conn, config ClientConfig) *Client

func (*Client) HandleDisconnect

func (client *Client) HandleDisconnect(handler func(disconnectionState error))

func (*Client) HandleEvents

func (client *Client) HandleEvents(handler func(event *primitives.Message))

func (*Client) SendCommand

func (client *Client) SendCommand(command *primitives.Message)

type ClientConfig added in v0.3.0

type ClientConfig struct {
	BufferSize     int   `yaml:"bufferSize"`
	MaxMessageSize int64 `yaml:"maxMessageSize"`

	WriteWait  time.Duration `yaml:"writeWait"`
	PongWait   time.Duration `yaml:"pongWait"`
	PingPeriod time.Duration `yaml:"pingPeriod"`
}

type Server

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

func NewServer

func NewServer(config ServerConfig) *Server

func (*Server) Handle added in v0.2.0

func (server *Server) Handle(endpoint string, handler func(client *Client))

func (*Server) HandleHttp added in v0.2.0

func (server *Server) HandleHttp(endpoint string, handler func(http.ResponseWriter, *http.Request))

func (*Server) Listen

func (server *Server) Listen() error

type ServerConfig added in v0.3.0

type ServerConfig struct {
	Server struct {
		Port string `yaml:"port"`
		Host string `yaml:"host"`
	} `yaml:"server"`

	ClientConfig ClientConfig `yaml:"client"`
}

func ConfigFromYamlFile added in v0.3.0

func ConfigFromYamlFile(filePath string, fileName string) (*ServerConfig, error)

Jump to

Keyboard shortcuts

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