wsserver

package
v1.5.7 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2025 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewClient

func NewClient(hub *WebsocketServer, w http.ResponseWriter, r *http.Request) (string, error)

func NewClientWithEvent added in v1.5.6

func NewClientWithEvent(hub *WebsocketServer, w http.ResponseWriter, r *http.Request, afterConnection, afterClose func(*Client)) (string, error)

Types

type Client

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

func (*Client) Close

func (c *Client) Close()

type Context

type Context struct {
	Keys map[string]any
	// contains filtered or unexported fields
}

func (*Context) Abort

func (c *Context) Abort()

func (*Context) BindJson

func (c *Context) BindJson(obj any) error

func (*Context) Body

func (c *Context) Body() []byte

func (*Context) Get

func (c *Context) Get(key string) (value any, exists bool)

func (*Context) GetBool

func (c *Context) GetBool(key string) (b bool)

func (*Context) GetDuration

func (c *Context) GetDuration(key string) (d time.Duration)

func (*Context) GetFloat64

func (c *Context) GetFloat64(key string) (f64 float64)

func (*Context) GetInt

func (c *Context) GetInt(key string) (i int)

func (*Context) GetInt64

func (c *Context) GetInt64(key string) (i64 int64)

func (*Context) GetString

func (c *Context) GetString(key string) (s string)

func (*Context) GetStringMap

func (c *Context) GetStringMap(key string) (sm map[string]any)

func (*Context) GetStringMapString

func (c *Context) GetStringMapString(key string) (sms map[string]string)

func (*Context) GetStringMapStringSlice

func (c *Context) GetStringMapStringSlice(key string) (smss map[string][]string)

func (*Context) GetStringSlice

func (c *Context) GetStringSlice(key string) (ss []string)

func (*Context) GetTime

func (c *Context) GetTime(key string) (t time.Time)

func (*Context) GetUint

func (c *Context) GetUint(key string) (ui uint)

func (*Context) GetUint64

func (c *Context) GetUint64(key string) (ui64 uint64)

func (*Context) Json

func (c *Context) Json(id string, data any)

func (*Context) Next

func (c *Context) Next()

func (*Context) Render

func (c *Context) Render(id string, msg []byte)

func (*Context) Set

func (c *Context) Set(key string, val any)

func (*Context) String

func (c *Context) String(id, body string)

type HandlerFunc

type HandlerFunc func(*Context)

type Message

type Message struct {
	ID   string
	Body []byte
}

type Option

type Option func(opt *option)

func WithHandler

func WithHandler(handles ...HandlerFunc) Option

type WebsocketServer

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

func New

func New(opts ...Option) *WebsocketServer

func (*WebsocketServer) Name

func (w *WebsocketServer) Name() string

func (*WebsocketServer) SendMessage

func (w *WebsocketServer) SendMessage(msg []byte)

func (*WebsocketServer) Start

func (w *WebsocketServer) Start(ctx context.Context) error

func (*WebsocketServer) Stop

func (w *WebsocketServer) Stop(ctx context.Context) error

Jump to

Keyboard shortcuts

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