ws

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2025 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var PadChannels = NewChannelOperator()

Functions

func HandleClientReadyMessage

func HandleClientReadyMessage(ready ws.ClientReady, client *Client, thisSession *ws.Session)

func HandlePadDelete

func HandlePadDelete(client *Client, padDeleteMessage PadDelete)

func HandleUserInfoUpdate

func HandleUserInfoUpdate(userInfo UserInfoUpdate, client *Client)

func KickSessionsFromPad

func KickSessionsFromPad(padID string)

func ServeWs

func ServeWs(hub *Hub, w http.ResponseWriter, r *http.Request, sessionStore *session.Store, fiber *fiber.Ctx)

ServeWs serveWs handles websocket requests from the peer.

func UpdatePadClients

func UpdatePadClients(pad *pad2.Pad)

Types

type AcceptCommitData

type AcceptCommitData struct {
	Type   string `json:"type"`
	NewRev int    `json:"newRev"`
}

type AcceptCommitMessage

type AcceptCommitMessage struct {
	Type string           `json:"type"`
	Data AcceptCommitData `json:"data"`
}

type AccessStatusMessage

type AccessStatusMessage struct {
	AccessStatus string `json:"accessStatus"`
}

type AuthSession

type AuthSession struct {
	PadID         string
	Token         string
	ReadOnlyPadId *string
	ReadOnly      bool
}

type ChannelOperator

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

func NewChannelOperator

func NewChannelOperator() ChannelOperator

func (*ChannelOperator) AddToQueue

func (c *ChannelOperator) AddToQueue(ch string, t Task)

type Client

type Client struct {

	// Buffered channel of outbound messages.
	Send      chan []byte
	Room      string
	SessionId string
	// contains filtered or unexported fields
}

Client is a middleman between the websocket connection and the hub.

func GetRoomSockets

func GetRoomSockets(padID string) []Client

func (*Client) Leave

func (c *Client) Leave()

func (*Client) SendPadDelete

func (c *Client) SendPadDelete()

func (*Client) SendUserDupMessage

func (c *Client) SendUserDupMessage()

type Hub

type Hub struct {

	// Inbound messages from the clients.
	Broadcast chan []byte

	// Register requests from the clients.
	Register chan *Client

	// Unregister requests from clients.
	Unregister chan *Client
	// contains filtered or unexported fields
}

Hub maintains the set of active clients and broadcasts messages to the clients.

var HubGlob *Hub

func NewHub

func NewHub() *Hub

func (*Hub) Run

func (h *Hub) Run()

type Message

type Message struct {
	Data clientVars2.ClientVars `json:"data"`
	Type string                 `json:"type"`
}

type NewChangesMessage

type NewChangesMessage struct {
	Type string                `json:"type"`
	Data NewChangesMessageData `json:"data"`
}

type NewChangesMessageData

type NewChangesMessageData struct {
	Type        string      `json:"type"`
	NewRev      int         `json:"newRev"`
	Changeset   string      `json:"changeset"`
	APool       apool.APool `json:"apool"`
	Author      string      `json:"author"`
	CurrentTime int         `json:"currentTime"`
	TimeDelta   int         `json:"timeDelta"`
}

type PadDelete

type PadDelete struct {
	Type string `json:"type"`
	Data struct {
		PadID string `json:"padId"`
	}
}

type PadDeleteMessage

type PadDeleteMessage struct {
	Disconnect string `json:"disconnect"`
}

type SessionInfo

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

type SessionStore

type SessionStore struct {
	// contains filtered or unexported fields
}
var SessionStoreInstance SessionStore

func NewSessionStore

func NewSessionStore(refresh *int) SessionStore

NewSessionStore @param refresh *int Number of milliseconds to refresh the session

/*

type Task

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

type UserDupMessage

type UserDupMessage struct {
	Disconnect string `json:"disconnect"`
}

type UserInfoUpdate

type UserInfoUpdate struct {
	Type string `json:"type"`
	Data struct {
		UserInfo struct {
			ColorId *string `json:"colorId"`
			IP      *string `json:"ip"`
			Name    *string `json:"name"`
			UserId  *string `json:"userId"`
		} `json:"userInfo"`
		Type string `json:"type"`
	} `json:"data"`
}

type UserInfoUpdateWrapper

type UserInfoUpdateWrapper struct {
	Event string         `json:"event"`
	Data  UserInfoUpdate `json:"data"`
}

Jump to

Keyboard shortcuts

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