wserve

package module
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2023 License: MIT Imports: 6 Imported by: 0

README

wserve

websocket based on gorilla secondary encapsulation

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultOptions

func DefaultOptions() *options

func New

func New(opts ...Option) (*WServe, *Hub)

Types

type Body

type Body struct {
	IFrom   IUser       `json:"-"`
	From    interface{} `json:"from"`
	To      interface{} `json:"to"`
	Message interface{} `json:"message"`
	Type    string      `json:"type"`
	Operate string      `json:"operate"`
}

func (*Body) Bytes

func (rb *Body) Bytes() []byte

type Client

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

type DUser

type DUser struct {
	Addr string
}

func (*DUser) Compare added in v0.1.0

func (u *DUser) Compare(addr interface{}) bool

func (*DUser) Major added in v0.1.0

func (u *DUser) Major() interface{}

type Hub

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

func (*Hub) Broadcast added in v1.0.2

func (h *Hub) Broadcast(body *Body)

func (*Hub) UseOperate

func (h *Hub) UseOperate(operate string, handle Operate)

type IStore added in v1.0.0

type IStore interface {
	Push(msg string) error
	Pull() (string, error)
}

type IUser

type IUser interface {
	Compare(interface{}) bool
	Major() interface{}
}

type Message

type Message struct {
	Request *http.Request
	// contains filtered or unexported fields
}

func (*Message) GetBody

func (m *Message) GetBody() *Body

func (*Message) OffClient

func (m *Message) OffClient(v interface{})

func (*Message) OnlineClients

func (m *Message) OnlineClients() interface{}

func (*Message) RadioMessage

func (m *Message) RadioMessage(v interface{})

func (*Message) SendMessage

func (m *Message) SendMessage(v interface{})

func (*Message) SendMessageTo

func (m *Message) SendMessageTo(u interface{}, v interface{})

type Operate

type Operate func(*Message)

type Option

type Option func(*options)

func Debug

func Debug() Option

func SetCertification

func SetCertification(fn func(*http.Request) (IUser, error)) Option

func SetCheckOrigin

func SetCheckOrigin(fn func(r *http.Request) bool) Option

func SetMaxMessageSize

func SetMaxMessageSize(v int64) Option

func SetPermissions added in v1.0.0

func SetPermissions(fn func(*http.Request, string) bool) Option

func SetReadBufferSize

func SetReadBufferSize(v int) Option

func SetReadDeadline

func SetReadDeadline(v int) Option

func SetWriteBufferSize

func SetWriteBufferSize(v int) Option

func SetWriteDeadline

func SetWriteDeadline(v int) Option

type Store added in v1.0.0

type Store struct {
}

func (*Store) Pull added in v1.0.0

func (s *Store) Pull() (string, error)

func (*Store) Push added in v1.0.0

func (s *Store) Push(msg string) error

type WServe

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

func (*WServe) GetHub added in v1.0.0

func (ws *WServe) GetHub() *Hub

func (*WServe) Run

func (ws *WServe) Run(addr string) error

func (*WServe) ServeHTTP

func (ws *WServe) ServeHTTP(w http.ResponseWriter, req *http.Request)

Jump to

Keyboard shortcuts

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