ws

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 11, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EventConnect             = "connect"
	EventUserConnected       = "userConnected"
	EventUserDisconnected    = "userDisconnected"
	EventSetLeader           = "setLeader"
	EventUserFailedToConnect = "userFailedToConnect"
	EventNewData             = "newData"
)

Variables

View Source
var (
	ErrInvalidMessage = errors.New("invalid message")
	ErrValidatingJWT  = errors.New("failed to validate jwt")
)

Functions

This section is empty.

Types

type Data

type Data struct {
	Elements string `json:"elements"`
	AppState string `json:"app_state"`
}

type JWTValidationResponse

type JWTValidationResponse struct {
	ID int `json:"id"`
}

type Message

type Message struct {
	Event string `json:"event"`
}

type MessageConnectRequest

type MessageConnectRequest struct {
	Message
	BoardID string `json:"board_id"`
	Jwt     string `json:"jwt"`
}

type MessageNewDataRequest

type MessageNewDataRequest struct {
	Message
	BoardID string `json:"board_id"`
	Jwt     string `json:"jwt"`
	Data    Data   `json:"data"`
}

type MessageNewDataResponse

type MessageNewDataResponse struct {
	Message
	BoardID string `json:"board_id"`
	Data    Data   `json:"data"`
}

type MessageSetLeaderRequest

type MessageSetLeaderRequest struct {
	Message
	BoardID string `json:"board_id"`
	Jwt     string `json:"jwt"`
}

type MessageSetLeaderResponse

type MessageSetLeaderResponse struct {
	Message
	BoardID string `json:"board_id"`
	UserID  string `json:"user_id"`
}

type MessageUserConnectedResponse

type MessageUserConnectedResponse struct {
	Message
	BoardID  string   `json:"board_id"`
	UserIDs  []string `json:"user_ids"`
	LeaderID string   `json:"leader_id"`
}

type MessageUserDisconnectedResponse

type MessageUserDisconnectedResponse struct {
	Message
	BoardID  string   `json:"board_id"`
	UserIDs  []string `json:"user_ids"`
	LeaderID string   `json:"leader_id"`
}

type MessageUserFailedToConnectResponse

type MessageUserFailedToConnectResponse struct {
	Message
	UserID string `json:"user_id"`
	Reason string `json:"reason"`
}

type WebSocketHandler

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

func NewWebSocketHandler

func NewWebSocketHandler(
	clientsStorage uStorage.Storage,
	roomStorage rStorage.Storage,
	jwtHeaderName string,
	jwtValidationURL string,
	boardValidationURL string,
	logger *zap.Logger,
) *WebSocketHandler

func (*WebSocketHandler) Handle

func (ws *WebSocketHandler) Handle(w http.ResponseWriter, r *http.Request)

Jump to

Keyboard shortcuts

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