websocket

package
v2.3.219 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2025 License: MIT Imports: 19 Imported by: 0

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