33 lines
669 B
Go
33 lines
669 B
Go
package models
|
|
|
|
import (
|
|
"sync"
|
|
|
|
"github.com/coder/websocket"
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
type Connections struct {
|
|
sync.RWMutex
|
|
Clients Clients
|
|
}
|
|
|
|
func NewConnections() *Connections {
|
|
return &Connections{
|
|
Clients: NewClients(),
|
|
}
|
|
}
|
|
|
|
// Connect a recieving websocket connection
|
|
func (c *Connections) ConnectRecievingWsConnection(id string, ctx *gin.Context) error {
|
|
return c.Clients.ConnectRecievingWsConnection(id, ctx)
|
|
}
|
|
|
|
func (c *Connections) RemoveClient(id string) {
|
|
c.Clients.RemoveClient(id)
|
|
}
|
|
|
|
func (c *Connections) DisconnectWsConnection(id string, code websocket.StatusCode, reason string) {
|
|
c.Clients.DisconnectWsConnection(id, code, reason)
|
|
}
|