websockets

package module
v0.0.0-...-785144f Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MessageTypeText = websocket.TextMessage
	MessageTypeData = websocket.BinaryMessage
)

Variables

This section is empty.

Functions

func ConnectionUpgrade

func ConnectionUpgrade() gin.HandlerFunc

func GetConnectionIDFromContext

func GetConnectionIDFromContext(c *gin.Context) string

func SetConnectionIDFromContext

func SetConnectionIDFromContext(id string, c *gin.Context)

func SocketsEventMiddleware

func SocketsEventMiddleware(pool *WsClientsPool) gin.HandlerFunc

Types

type Message

type Message struct {
	MessageType MessageType
	Data        []byte
}

func GetIncomingMessageFromContext

func GetIncomingMessageFromContext(c *gin.Context) Message

type MessageType

type MessageType int

type WSContextConst

type WSContextConst string
const (
	ContextConstWSPool       WSContextConst = "ContextConstWSPool"
	ContextConstConnectionID WSContextConst = "ContextConstConnectionID"
	ContextIncomingMessage   WSContextConst = "ContextIncomingMessage"
)

type WsClientArray

type WsClientArray []*WsConnection

type WsClientsPool

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

func GetWSPoolContext

func GetWSPoolContext(c *gin.Context) *WsClientsPool

Ws

func NewPool

func NewPool() *WsClientsPool

func NewPoolWithClients

func NewPoolWithClients(clientsId string, clients *WsClientArray) *WsClientsPool

func (*WsClientsPool) Append

func (p *WsClientsPool) Append(client *WsConnection, id string)

func (*WsClientsPool) Broadcast

func (p *WsClientsPool) Broadcast(event interface{})

func (*WsClientsPool) Delete

func (p *WsClientsPool) Delete(id string)

func (*WsClientsPool) GetConnectionsByID

func (p *WsClientsPool) GetConnectionsByID(id string) *WsClientArray

func (*WsClientsPool) Send

func (p *WsClientsPool) Send(clientId string, event interface{})

type WsConnection

type WsConnection struct {
	MessagesChannel *chan Message
	Done            chan bool
	// contains filtered or unexported fields
}

func NewWsConnection

func NewWsConnection(conn *websocket.Conn, id string, messages *chan Message, pool *WsClientsPool) *WsConnection

Jump to

Keyboard shortcuts

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