Documentation
¶
Index ¶
- Variables
- func CL4MethodHandler(client *Client, message *PacketUPL)
- func CL4ProtocolDetect(client *Client)
- func GatherSnowflakeIDs(clientstore interface{}) map[interface{}]*Client
- func GatherUUIDs(clientstore interface{}) map[interface{}]*Client
- func GatherUserObjects(clientstore interface{}) map[interface{}]*Client
- func GatherUsernames(clientstore interface{}) map[interface{}][]*Client
- func GetValue(slice []interface{}, target interface{}) int
- func JSONDump(message any) []byte
- func MulticastMessage(clients map[snowflake.ID]*Client, message any)
- func RemoveValue(slice []interface{}, indexRemove int) []interface{}
- func ScratchMethodHandler(client *Client, message *Scratch)
- func ScratchProtocolDetect(client *Client)
- func SessionHandler(con *websocket.Conn, manager *Manager)
- func TempCopyRooms(origin map[interface{}]*Room) map[interface{}]*Room
- func UnicastMessage(client *Client, message any)
- type Client
- func (client *Client) CloseWithMessage(statuscode int, closeMessage string)
- func (client *Client) GenerateUserObject() *UserObject
- func (client *Client) HandleIDSet(message *PacketUPL) bool
- func (client *Client) MessageHandler(manager *Manager)
- func (client *Client) RequireIDBeingSet(message *PacketUPL) bool
- func (client *Client) TempCopy() *Client
- type Manager
- type PacketUPL
- type Room
- func (room *Room) BroadcastGmsg(value interface{})
- func (room *Room) BroadcastGvar(name interface{}, value interface{})
- func (room *Room) BroadcastUserlistEvent(event string, client *Client, exclude bool)
- func (room *Room) FindClient(query interface{}) interface{}
- func (room *Room) GenerateUserList() []*UserObject
- func (room *Room) SubscribeClient(client *Client)
- func (room *Room) UnsubscribeClient(client *Client)
- type Scratch
- type UserObject
Constants ¶
This section is empty.
Variables ¶
var ServerVersion string = "0.1.0-golang"
Functions ¶
func CL4MethodHandler ¶
CL4MethodHandler is a method that s created when a CL-formatted message gets handled by MessageHandler.
func CL4ProtocolDetect ¶
func CL4ProtocolDetect(client *Client)
func GatherSnowflakeIDs ¶
func GatherSnowflakeIDs(clientstore interface{}) map[interface{}]*Client
Gathers a map of all Snowflake IDs representing Clients in a Room or Manager.
func GatherUUIDs ¶
func GatherUUIDs(clientstore interface{}) map[interface{}]*Client
Gathers a map of all UUIDs representing Clients in a Room or Manager.
func GatherUserObjects ¶
func GatherUserObjects(clientstore interface{}) map[interface{}]*Client
Gathers a map of all UserObjects representing Clients in a Room or Manager.
func GatherUsernames ¶
func GatherUsernames(clientstore interface{}) map[interface{}][]*Client
Gathers a map of all Usernames representing multiple Clients in a Room or Manager.
func MulticastMessage ¶
MulticastMessage broadcasts a payload to multiple clients.
func RemoveValue ¶
func RemoveValue(slice []interface{}, indexRemove int) []interface{}
func ScratchMethodHandler ¶
ScratchMethodHandler is a method that gets created when a Scratch-formatted message gets handled by MessageHandler.
func ScratchProtocolDetect ¶
func ScratchProtocolDetect(client *Client)
func SessionHandler ¶
SessionHandler is the root function that makes CloudLink work. As soon as a client request gets upgraded to the websocket protocol, this function should be called.
func TempCopyRooms ¶
Creates a temporary deep copy of a client's rooms map attribute.
func UnicastMessage ¶
UnicastMessageAny broadcasts a payload to a singular client.
Types ¶
type Client ¶
type Client struct {
// Lock state for rooms
sync.RWMutex
// contains filtered or unexported fields
}
The client struct serves as a template for handling websocket sessions. It stores a client's UUID, Snowflake ID, manager and websocket connection pointer(s).
func NewClient ¶
NewClient assigns a UUID and Snowflake ID to a websocket client, and returns a initialized Client struct for use with a manager's AddClient.
func (*Client) CloseWithMessage ¶
func (*Client) GenerateUserObject ¶
func (client *Client) GenerateUserObject() *UserObject
Generates a value for client identification.
func (*Client) HandleIDSet ¶
func (*Client) MessageHandler ¶
func (*Client) RequireIDBeingSet ¶
type Manager ¶
type Manager struct {
// Configuration settings
Config struct {
RejectClients bool
CheckIPAddresses bool
EnableMOTD bool
MOTDMessage string
}
// Used for generating Snowflake IDs
SnowflakeIDNode *snowflake.Node
// Locks states before registering sessions
sync.RWMutex
// contains filtered or unexported fields
}
func DummyManager ¶
func DummyManager(name interface{}) *Manager
Dummy Managers function identically to a normal manager. However, they are used for selecting specific clients to multicast to.
func (*Manager) CreateRoom ¶
func (*Manager) DeleteRoom ¶
func (manager *Manager) DeleteRoom(name interface{})
func (*Manager) RemoveClient ¶
type PacketUPL ¶
type PacketUPL struct {
Cmd string `json:"cmd"`
Name interface{} `json:"name,omitempty"`
Val interface{} `json:"val,omitempty"`
ID interface{} `json:"id,omitempty"`
Rooms interface{} `json:"rooms,omitempty"`
Listener interface{} `json:"listener,omitempty"`
Code string `json:"code,omitempty"`
CodeID int `json:"code_id,omitempty"`
Mode string `json:"mode,omitempty"`
Origin *UserObject `json:"origin,omitempty"`
Details string `json:"details,omitempty"`
}
This structure represents the JSON formatting used for the current CloudLink formatting scheme. Values that are not specific to one type are represented with interface{}.
type Room ¶
type Room struct {
// Locks states before subscribing/unsubscribing clients
sync.RWMutex
// contains filtered or unexported fields
}
func (*Room) BroadcastGmsg ¶
func (room *Room) BroadcastGmsg(value interface{})
func (*Room) BroadcastGvar ¶
func (room *Room) BroadcastGvar(name interface{}, value interface{})
func (*Room) BroadcastUserlistEvent ¶
func (*Room) FindClient ¶
func (room *Room) FindClient(query interface{}) interface{}
Takes a UUID, Snowflake ID, Username, or UserObject query and returns either a single Client (UUID, Snowflake, UserObject) or multiple Clients (username).
func (*Room) GenerateUserList ¶
func (room *Room) GenerateUserList() []*UserObject
Gathers all user objects in a room, and generates a userlist.
func (*Room) SubscribeClient ¶
func (*Room) UnsubscribeClient ¶
type Scratch ¶
type Scratch struct {
Method string `json:"method"`
ProjectID interface{} `json:"project_id,omitempty"`
Username string `json:"user,omitempty"`
Value interface{} `json:"value"`
Name interface{} `json:"name,omitempty"`
NewName interface{} `json:"new_name,omitempty"`
}
This structure represents the JSON formatting the Scratch cloud variable protocol uses. Values that are not specific to one type are represented with interface{}.