Documentation ¶
Index ¶
- Constants
- func ConnectionUpgrade() gin.HandlerFunc
- func GetConnectionIDFromContext(c *gin.Context) string
- func SetConnectionIDFromContext(id string, c *gin.Context)
- func SocketsEventMiddleware(pool *WsClientsPool) gin.HandlerFunc
- type Message
- type MessageType
- type WSContextConst
- type WsClientArray
- type WsClientsPool
- type WsConnection
Constants ¶
View Source
const ( MessageTypeText = websocket.TextMessage MessageTypeData = websocket.BinaryMessage )
Variables ¶
This section is empty.
Functions ¶
func ConnectionUpgrade ¶
func ConnectionUpgrade() gin.HandlerFunc
func SocketsEventMiddleware ¶
func SocketsEventMiddleware(pool *WsClientsPool) gin.HandlerFunc
Types ¶
type Message ¶
type Message struct { MessageType MessageType Data []byte }
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 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
Click to show internal directories.
Click to hide internal directories.