Documentation
¶
Index ¶
- type Client
- type Message
- type Server
- func (s *Server) Broadcast(message *Message)
- func (s *Server) BroadcastToRoom(room string, message *Message)
- func (s *Server) GetClientCount() int
- func (s *Server) GetClients() []*Client
- func (s *Server) GetRoomClients(room string) []*Client
- func (s *Server) GetRoomCount() int
- func (s *Server) HandleConnection(c *websocket.Conn)
- func (s *Server) Run(ctx context.Context)
- func (s *Server) SendToClient(clientID string, message *Message)
- func (s *Server) Upgrade() fiber.Handler
- func (s *Server) Use(middleware func(*Client) error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
ID string
Conn *websocket.Conn
Server *Server
Send chan []byte
Rooms map[string]bool
Metadata map[string]interface{}
// contains filtered or unexported fields
}
Client represents a WebSocket client
func (*Client) SendMessage ¶
Send sends a message to the client
type Message ¶
type Message struct {
Type string `json:"type"`
Room string `json:"room,omitempty"`
Data interface{} `json:"data"`
From string `json:"from,omitempty"`
To string `json:"to,omitempty"`
Meta map[string]interface{} `json:"meta,omitempty"`
Timestamp time.Time `json:"timestamp"`
}
Message represents a WebSocket message
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server manages WebSocket connections
func (*Server) BroadcastToRoom ¶
BroadcastToRoom sends a message to all clients in a room
func (*Server) GetClientCount ¶
GetClientCount returns the number of connected clients
func (*Server) GetClients ¶
GetClients returns all connected clients
func (*Server) GetRoomClients ¶
GetRoomClients returns all clients in a specific room
func (*Server) GetRoomCount ¶
GetRoomCount returns the number of rooms
func (*Server) HandleConnection ¶
HandleConnection creates a Fiber WebSocket handler
func (*Server) SendToClient ¶
SendToClient sends a message to a specific client
Click to show internal directories.
Click to hide internal directories.