mirror of
https://github.com/mumble-voip/grumble.git
synced 2025-12-20 06:10:00 -08:00
67 lines
1.4 KiB
Go
67 lines
1.4 KiB
Go
// Copyright (c) 2010 The Grumble Authors
|
|
// The use of this source code is goverened by a BSD-style
|
|
// license that can be found in the LICENSE-file.
|
|
|
|
package main
|
|
|
|
// A Mumble channel
|
|
type Channel struct {
|
|
Id int
|
|
Name string
|
|
Temporary bool
|
|
Position int
|
|
|
|
clients map[uint32]*Client
|
|
|
|
parent *Channel
|
|
children map[int]*Channel
|
|
|
|
// ACL
|
|
ACL []*ChannelACL
|
|
InheritACL bool
|
|
|
|
// Groups
|
|
Groups map[string]*Group
|
|
|
|
// Links
|
|
Links map[int]*Channel
|
|
|
|
// Blobs
|
|
Description string
|
|
DescriptionHash []byte
|
|
}
|
|
|
|
func NewChannel(id int, name string) (channel *Channel) {
|
|
channel = new(Channel)
|
|
channel.Id = id
|
|
channel.Name = name
|
|
channel.clients = make(map[uint32]*Client)
|
|
channel.children = make(map[int]*Channel)
|
|
channel.ACL = []*ChannelACL{}
|
|
channel.Groups = map[string]*Group{}
|
|
return
|
|
}
|
|
|
|
// Add a child channel to a channel
|
|
func (channel *Channel) AddChild(child *Channel) {
|
|
child.parent = channel
|
|
channel.children[child.Id] = child
|
|
}
|
|
|
|
// Remove a child channel from a parent
|
|
func (channel *Channel) RemoveChild(child *Channel) {
|
|
child.parent = nil
|
|
channel.children[child.Id] = nil, false
|
|
}
|
|
|
|
// Add client
|
|
func (channel *Channel) AddClient(client *Client) {
|
|
channel.clients[client.Session] = client
|
|
client.Channel = channel
|
|
}
|
|
|
|
// Remove client
|
|
func (channel *Channel) RemoveClient(client *Client) {
|
|
channel.clients[client.Session] = nil, false
|
|
client.Channel = nil
|
|
}
|