websocket

package
v2.4.4 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2025 License: MIT Imports: 17 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	NewClientListenerType          = "new-client"
	NewClientSessionListenerType   = "new-client-session"
	CloseClientListenerType        = "close-client"
	CloseClientSessionListenerType = "close-client-session"
	NewMessageListenerType         = "new-message"
)

Variables

View Source
var (
	ErrMaxCountSessions = apperr.New("max_count_sessions",
		apperr.WithTextTranslate(translator.Translate{translator.RU: "Превышено максимальное количество сессий", translator.EN: "Maximum number of sessions exceeded"}),
		apperr.WithCode(code.Unauthenticated))
)
View Source
var (
	MaxMessageSize int64 = 512
)

Functions

This section is empty.

Types

type Client

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

type Listener

type Listener struct {
	Event     string
	Message   []byte
	ClientID  int
	SessionID string
}

type Message

type Message struct {
	Type          string      `json:"type"`
	Action        string      `json:"action"`
	Message       interface{} `json:"message"`
	From          *int        `json:"from,omitempty"`
	To            []int       `json:"to,omitempty"`
	ToSession     *string     `json:"to_session,omitempty"`
	ExceptSession *string     `json:"except_session,omitempty"`
	ContentType   int         `json:"-"`
}

type WebSocket

type WebSocket interface {
	InitHandler(api *gin.RouterGroup)
	SendMessage(ctx context.Context, m Message) error
	RegisterClientListener() <-chan Listener
	ShutDown()
}

func New

func New(lenChan int, clientMaxCount ...int) WebSocket

Jump to

Keyboard shortcuts

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