Documentation
¶
Index ¶
Constants ¶
View Source
const ( TypeTyping = "typing" TypeMessage = "message" TypePeerList = "peer.list" TypePeerInfo = "peer.info" TypePeerJoin = "peer.join" TypePeerLeave = "peer.leave" TypePeerRateLimited = "peer.ratelimited" TypeRoomDispose = "room.dispose" TypeRoomFull = "room.full" TypeNotice = "notice" TypeHandle = "handle" )
Types of messages sent to peers.
Variables ¶
This section is empty.
Functions ¶
func GenerateGUID ¶
GenerateGUID generates a cryptographically random, alphanumeric string of length n.
Types ¶
type Config ¶
type Config struct { Address string `koanf:"address"` RootURL string `koanf:"root_url"` Name string `koanf:"name"` RoomIDLen int `koanf:"room_id_length"` MaxCachedMessages int `koanf:"max_cached_messages"` MaxMessageLen int `koanf:"max_message_length"` WSTimeout time.Duration `koanf:"websocket_timeout"` MaxMessageQueue int `koanf:"max_message_queue"` RateLimitInterval time.Duration `koanf:"rate_limit_interval"` RateLimitMessages int `koanf:"rate_limit_messages"` MaxRooms int `koanf:"max_rooms"` MaxPeersPerRoom int `koanf:"max_peers_per_room"` PeerHandleFormat string `koanf:"peer_handle_format"` RoomTimeout time.Duration `koanf:"room_timeout"` RoomAge time.Duration `koanf:"room_age"` SessionCookie string `koanf:"session_cookie"` Storage string `koanf:"storage"` }
Config represents the app configuration.
type Hub ¶
Hub acts as the controller and container for all chat rooms.
func (*Hub) ActivateRoom ¶
ActivateRoom loads a room from the store into the hub if it's not already active.
type Peer ¶
type Peer struct { // Peer's chat handle. ID string Handle string // contains filtered or unexported fields }
Peer represents an individual peer / connection into a room.
func (*Peer) RunListener ¶
func (p *Peer) RunListener()
RunListener is a blocking function that reads incoming messages from a peer's WS connection until its dropped or there's an error. This should be invoked as a goroutine.
type Room ¶
type Room struct { ID string Name string Password []byte // contains filtered or unexported fields }
Room represents a chat room.
func (*Room) AddPeer ¶
AddPeer adds a new peer to the room given a WS connection from an HTTP handler.
Click to show internal directories.
Click to hide internal directories.