Documentation
¶
Index ¶
- Variables
- func GenerateSecureToken(n int) (string, error)
- func SendMessage(ws *websocket.Conn, msg any) error
- type WebsocketHandler
- func (h *WebsocketHandler) InitialiseWebsocket(w http.ResponseWriter, r *http.Request)
- func (h *WebsocketHandler) RegisterWithPin(pin uint, device *models.Device) (*models.Device, error)
- func (h *WebsocketHandler) StartSession(userID uint, deviceID uint, questionStr string) (*models.Session, error)
- func (h *WebsocketHandler) StopSession(session *models.Session) error
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrDeviceNotConnected = errors.New("Device is currently connected, can not start session")
View Source
var ErrQuestionContainsInvalidChar = errors.New("Question contains a invalid character")
View Source
var ErrQuestionToLong = errors.New("Question length exteeds 80 characters")
Functions ¶
func GenerateSecureToken ¶
Types ¶
type WebsocketHandler ¶
type WebsocketHandler struct {
Connections map[uint]*websocketConnection // connection id -> connection
ConnectedDevices map[uint]uint // device id -> connection id
// contains filtered or unexported fields
}
func NewWebsocketHandler ¶
func NewWebsocketHandler(cfg *config.Config, db *gorm.DB) *WebsocketHandler
func (*WebsocketHandler) InitialiseWebsocket ¶
func (h *WebsocketHandler) InitialiseWebsocket(w http.ResponseWriter, r *http.Request)
InitialiseWebsocket
@Summary Open a connection to the device websocket API @Description Open a websocket connection used by devices to communicate with the server. @Description Devices get notified about session changes and send votes via this connection. @Tags device_websocket @Accept json @Produce json @Success 101 {string} string "Switching Protocols (WebSocket Upgrade)" @Failure 400 {string} string "Bad Request" @Router /ws [get]
func (*WebsocketHandler) RegisterWithPin ¶
func (*WebsocketHandler) StartSession ¶
func (*WebsocketHandler) StopSession ¶
func (h *WebsocketHandler) StopSession(session *models.Session) error
Click to show internal directories.
Click to hide internal directories.