gumble

package
v0.0.0-...-944ce18 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2020 License: MPL-2.0 Imports: 16 Imported by: 6

Documentation

Overview

Package gumble is a client for the Mumble voice chat software.

Getting started

1. Create a new Config to hold your connection settings:

config := gumble.NewConfig()
config.Username = "gumble-test"

2. Attach event listeners to the configuration:

config.Attach(gumbleutil.Listener{
    TextMessage: func(e *gumble.TextMessageEvent) {
        fmt.Printf("Received text message: %s\n", e.Message)
    },
})

3. Connect to the server:

client, err := gumble.Dial("example.com:64738", config)
if err != nil {
    panic(err)
}

Audio codecs

Currently, only the Opus codec (https://www.opus-codec.org/) is supported for transmitting and receiving audio. It can be enabled by importing the following package for its side effect:

import (
    _ "layeh.com/gumble/opus"
)

To ensure that gumble clients can always transmit and receive audio to and from your server, add the following line to your murmur configuration file:

opusthreshold=0

Thread safety

As a general rule, a Client everything that is associated with it (Users, Channels, Config, etc.), is thread-unsafe. Accessing or modifying those structures should only be done from inside of an event listener or via Client.Do.

Index

Constants

View Source
const (
	ACLGroupEveryone       = "all"
	ACLGroupAuthenticated  = "auth"
	ACLGroupInsideChannel  = "in"
	ACLGroupOutsideChannel = "out"
)

ACL group names that are built-in.

View Source
const (
	// AudioMaximumSampleRate is the maximum audio sample rate (in hertz) for
	// incoming and outgoing audio.
	AudioMaximumSampleRate = 48000

	// AudioSampleRate is the audio sample rate (in hertz) for incoming and
	// outgoing audio.
	AudioSampleRate = 48000

	// AudioDefaultIntervalMS is the default interval in milliseconds that audio
	// packets are sent at.
	AudioDefaultIntervalMS = 60

	// AudioDefaultInterval is the default interval that audio packets are sent
	// at.
	AudioDefaultInterval = AudioDefaultIntervalMS * time.Millisecond

	// AudioDefaultFrameSize is the number of audio frames that should be sent in
	// a AudioDefaultInterval window.
	AudioDefaultFrameSize = (AudioSampleRate * AudioDefaultIntervalMS) / 1000

	// AudioMaximumFrameSize is the maximum audio frame size from another user
	// that will be processed.
	AudioMaximumFrameSize = AudioMaximumSampleRate / 1000 * 60

	// AudioDefaultDataBytes is the default number of bytes that an audio frame
	// can use.
	AudioDefaultDataBytes = 40

	// AudioChannels is the number of audio channels that are contained in an
	// audio stream.
	AudioChannels = 1
)
View Source
const ClientVersion = 1<<16 | 3<<8 | 0

ClientVersion is the protocol version that Client implements.

View Source
const DefaultPort = 64738

DefaultPort is the default port on which Mumble servers listen.

Variables

This section is empty.

Functions

func RegisterAudioCodec

func RegisterAudioCodec(id int, codec AudioCodec)

RegisterAudioCodec registers an audio codec that can be used for encoding and decoding outgoing and incoming audio data. The function panics if the ID is invalid.

Types

type ACL

type ACL struct {
	// The channel to which the ACL belongs.
	Channel *Channel
	// The ACL's groups.
	Groups []*ACLGroup
	// The ACL's rules.
	Rules []*ACLRule
	// Does the ACL inherits the parent channel's ACLs?
	Inherits bool
}

ACL contains a list of ACLGroups and ACLRules linked to a channel.

type ACLEvent

type ACLEvent struct {
	Client *Client
	ACL    *ACL
}

ACLEvent is the event that is passed to EventListener.OnACL.

type ACLGroup

type ACLGroup struct {
	// The ACL group name.
	Name string
	// Is the group inherited from the parent channel's ACL?
	Inherited bool
	// Are group members are inherited from the parent channel's ACL?
	InheritUsers bool
	// Can the group be inherited by child channels?
	Inheritable bool
	// The users who are explicitly added to, explicitly removed from, and
	// inherited into the group.
	UsersAdd, UsersRemove, UsersInherited map[uint32]*ACLUser
}

ACLGroup is a named group of registered users which can be used in an ACLRule.

type ACLRule

type ACLRule struct {
	// Does the rule apply to the channel in which the rule is defined?
	AppliesCurrent bool
	// Does the rule apply to the children of the channel in which the rule is
	// defined?
	AppliesChildren bool
	// Is the rule inherited from the parent channel's ACL?
	Inherited bool

	// The permissions granted by the rule.
	Granted Permission
	// The permissions denied by the rule.
	Denied Permission

	// The ACL user the rule applies to. Can be nil.
	User *ACLUser
	// The ACL group the rule applies to. Can be nil.
	Group *ACLGroup
}

ACLRule is a set of granted and denied permissions given to an ACLUser or ACLGroup.

type ACLUser

type ACLUser struct {
	// The user ID of the user.
	UserID uint32
	// The name of the user.
	Name string
}

ACLUser is a registered user who is part of or can be part of an ACL group or rule.

type AccessTokens

type AccessTokens []string

AccessTokens are additional passwords that can be provided to the server to gain access to restricted channels.

type AudioBuffer

type AudioBuffer []int16

AudioBuffer is a slice of PCM audio samples.

type AudioCodec

type AudioCodec interface {
	ID() int
	NewEncoder() AudioEncoder
	NewDecoder() AudioDecoder
}

AudioCodec can create a encoder and a decoder for outgoing and incoming data.

type AudioDecoder

type AudioDecoder interface {
	ID() int
	Decode(data []byte, frameSize int) ([]int16, error)
	Reset()
}

AudioDecoder decodes an encoded byte slice to a chunk of PCM audio samples.

type AudioEncoder

type AudioEncoder interface {
	ID() int
	Encode(pcm []int16, mframeSize, maxDataBytes int) ([]byte, error)
	Reset()
}

AudioEncoder encodes a chunk of PCM audio samples to a certain type.

type AudioListener

type AudioListener interface {
	OnAudioStream(e *AudioStreamEvent)
}

AudioListener is the interface that must be implemented by types wishing to receive incoming audio data from the server.

OnAudioStream is called when an audio stream for a user starts. It is the implementer's responsibility to continuously process AudioStreamEvent.C until it is closed.

type AudioListeners

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

AudioListeners is a list of audio listeners. Each attached listener is called in sequence when a new user audio stream begins.

func (*AudioListeners) Attach

func (e *AudioListeners) Attach(listener AudioListener) Detacher

Attach adds a new audio listener to the end of the current list of listeners.

type AudioPacket

type AudioPacket struct {
	Client *Client
	Sender *User
	Target *VoiceTarget

	AudioBuffer

	HasPosition bool
	X, Y, Z     float32
}

AudioPacket contains incoming audio samples and information.

type AudioStreamEvent

type AudioStreamEvent struct {
	Client *Client
	User   *User
	C      <-chan *AudioPacket
}

AudioStreamEvent is event that is passed to AudioListener.OnAudioStream.

type Ban

type Ban struct {
	// The banned IP address.
	Address net.IP
	// The IP mask that the ban applies to.
	Mask net.IPMask
	// The name of the banned user.
	Name string
	// The certificate hash of the banned user.
	Hash string
	// The reason for the ban.
	Reason string
	// The start time from which the ban applies.
	Start time.Time
	// How long the ban is for.
	Duration time.Duration
	// contains filtered or unexported fields
}

Ban represents an entry in the server ban list.

This type should not be initialized manually. Instead, create new ban entries using BanList.Add().

func (*Ban) Ban

func (b *Ban) Ban()

Ban will ban the user from the server. This is only useful if Unban() was called on the ban entry.

func (*Ban) SetAddress

func (b *Ban) SetAddress(address net.IP)

SetAddress sets the banned IP address.

func (*Ban) SetDuration

func (b *Ban) SetDuration(duration time.Duration)

SetDuration changes the duration of the ban.

func (*Ban) SetMask

func (b *Ban) SetMask(mask net.IPMask)

SetMask sets the IP mask that the ban applies to.

func (*Ban) SetReason

func (b *Ban) SetReason(reason string)

SetReason changes the reason for the ban.

func (*Ban) Unban

func (b *Ban) Unban()

Unban will unban the user from the server.

type BanList

type BanList []*Ban

BanList is a list of server ban entries.

Whenever a ban is changed, it does not come into effect until the ban list is sent back to the server.

func (*BanList) Add

func (b *BanList) Add(address net.IP, mask net.IPMask, reason string, duration time.Duration) *Ban

Add creates a new ban list entry with the given parameters.

type BanListEvent

type BanListEvent struct {
	Client  *Client
	BanList BanList
}

BanListEvent is the event that is passed to EventListener.OnBanList.

type Channel

type Channel struct {
	// The channel's unique ID.
	ID uint32
	// The channel's name.
	Name string
	// The channel's parent. nil if the channel is the root channel.
	Parent *Channel
	// The channels directly underneath the channel.
	Children Channels
	// The channels that are linked to the channel.
	Links Channels
	// The users currently in the channel.
	Users Users
	// The channel's description. Contains the empty string if the channel does
	// not have a description, or if it needs to be requested.
	Description string
	// The channel's description hash. nil if Channel.Description has
	// been populated.
	DescriptionHash []byte
	// The maximum number of users allowed in the channel. If the value is zero,
	// the maximum number of users per-channel is dictated by the server's
	// "usersperchannel" setting.
	MaxUsers uint32
	// The position at which the channel should be displayed in an ordered list.
	Position int32
	// Is the channel temporary?
	Temporary bool
	// contains filtered or unexported fields
}

Channel represents a channel in the server's channel tree.

func (*Channel) Add

func (c *Channel) Add(name string, temporary bool)

Add will add a sub-channel to the given channel.

func (*Channel) Find

func (c *Channel) Find(names ...string) *Channel

Find returns a channel whose path (by channel name) from the current channel is equal to the arguments passed.

For example, given the following server channel tree:

Root
  Child 1
  Child 2
    Child 2.1
    Child 2.2
      Child 2.2.1
  Child 3

To get the "Child 2.2.1" channel:

root.Find("Child 2", "Child 2.2", "Child 2.2.1")

func (*Channel) IsRoot

func (c *Channel) IsRoot() bool

IsRoot returns true if the channel is the server's root channel.

func (c *Channel) Link(channel ...*Channel)

Link links the given channels to the channel.

func (*Channel) Permission

func (c *Channel) Permission() *Permission

Permission returns the permissions the user has in the channel, or nil if the permissions are unknown.

func (*Channel) Remove

func (c *Channel) Remove()

Remove will remove the given channel and all sub-channels from the server's channel tree.

func (*Channel) RequestACL

func (c *Channel) RequestACL()

RequestACL requests that the channel's ACL to be sent to the client.

func (*Channel) RequestDescription

func (c *Channel) RequestDescription()

RequestDescription requests that the actual channel description (i.e. non-hashed) be sent to the client.

func (*Channel) RequestPermission

func (c *Channel) RequestPermission()

RequestPermission requests that the channel's permission information to be sent to the client.

Note: the server will not reply to the request if the client has up-to-date permission information.

func (*Channel) Send

func (c *Channel) Send(message string, recursive bool)

Send will send a text message to the channel.

func (*Channel) SetDescription

func (c *Channel) SetDescription(description string)

SetDescription will set the description of the channel.

func (*Channel) SetMaxUsers

func (c *Channel) SetMaxUsers(maxUsers uint32)

SetMaxUsers will set the maximum number of users allowed in the channel.

func (*Channel) SetName

func (c *Channel) SetName(name string)

SetName will set the name of the channel. This will have no effect if the channel is the server's root channel.

func (*Channel) SetPosition

func (c *Channel) SetPosition(position int32)

SetPosition will set the position of the channel.

func (c *Channel) Unlink(channel ...*Channel)

Unlink unlinks the given channels from the channel. If no arguments are passed, all linked channels are unlinked.

type ChannelChangeEvent

type ChannelChangeEvent struct {
	Client  *Client
	Type    ChannelChangeType
	Channel *Channel
}

ChannelChangeEvent is the event that is passed to EventListener.OnChannelChange.

type ChannelChangeType

type ChannelChangeType int

ChannelChangeType is a bitmask of items that changed for a channel.

const (
	ChannelChangeCreated ChannelChangeType = 1 << iota
	ChannelChangeRemoved
	ChannelChangeMoved
	ChannelChangeName
	ChannelChangeLinks
	ChannelChangeDescription
	ChannelChangePosition
	ChannelChangePermission
	ChannelChangeMaxUsers
)

Channel change items.

func (ChannelChangeType) Has

func (c ChannelChangeType) Has(changeType ChannelChangeType) bool

Has returns true if the ChannelChangeType has changeType part of its bitmask.

type Channels

type Channels map[uint32]*Channel

Channels is a map of server channels.

func (Channels) Find

func (c Channels) Find(names ...string) *Channel

Find returns a channel whose path (by channel name) from the server root channel is equal to the arguments passed. nil is returned if c does not containt the root channel.

type Client

type Client struct {
	// The User associated with the client.
	Self *User
	// The client's configuration.
	Config *Config
	// The underlying Conn to the server.
	Conn *Conn

	// The users currently connected to the server.
	Users Users
	// The connected server's channels.
	Channels Channels

	// A collection containing the server's context actions.
	ContextActions ContextActions

	// The audio encoder used when sending audio to the server.
	AudioEncoder AudioEncoder

	// To whom transmitted audio will be sent. The VoiceTarget must have already
	// been sent to the server for targeting to work correctly. Setting to nil
	// will disable voice targeting (i.e. switch back to regular speaking).
	VoiceTarget *VoiceTarget
	// contains filtered or unexported fields
}

Client is the type used to create a connection to a server.

func Dial

func Dial(addr string, config *Config) (*Client, error)

Dial is an alias of DialWithDialer(new(net.Dialer), addr, config, nil).

func DialWithDialer

func DialWithDialer(dialer *net.Dialer, addr string, config *Config, tlsConfig *tls.Config) (*Client, error)

DialWithDialer connects to the Mumble server at the given address.

The function returns after the connection has been established, the initial server information has been synced, and the OnConnect handlers have been called.

nil and an error is returned if server synchronization does not complete by min(time.Now() + dialer.Timeout, dialer.Deadline), or if the server rejects the client.

func (*Client) AudioOutgoing

func (c *Client) AudioOutgoing() chan<- AudioBuffer

AudioOutgoing creates a new channel that outgoing audio data can be written to. The channel must be closed after the audio stream is completed. Only a single channel should be open at any given time (i.e. close the channel before opening another).

func (*Client) Disconnect

func (c *Client) Disconnect() error

Disconnect disconnects the client from the server.

func (*Client) Do

func (c *Client) Do(f func())

Do executes f in a thread-safe manner. It ensures that Client and its associated data will not be changed during the lifetime of the function call.

func (*Client) RequestBanList

func (c *Client) RequestBanList()

RequestBanList requests that the server's ban list be sent to the client.

func (*Client) RequestUserList

func (c *Client) RequestUserList()

RequestUserList requests that the server's registered user list be sent to the client.

func (*Client) Send

func (c *Client) Send(message Message)

Send will send a Message to the server.

func (*Client) State

func (c *Client) State() State

State returns the current state of the client.

type Config

type Config struct {
	// User name used when authenticating with the server.
	Username string
	// Password used when authenticating with the server. A password is not
	// usually required to connect to a server.
	Password string
	// The initial access tokens to the send to the server. Access tokens can be
	// resent to the server using:
	//  client.Send(config.Tokens)
	Tokens AccessTokens

	// AudioInterval is the interval at which audio packets are sent. Valid
	// values are: 10ms, 20ms, 40ms, and 60ms.
	AudioInterval time.Duration
	// AudioDataBytes is the number of bytes that an audio frame can use.
	AudioDataBytes int

	// The event listeners used when client events are triggered.
	Listeners      Listeners
	AudioListeners AudioListeners
}

Config holds the Mumble configuration used by Client. A single Config should not be shared between multiple Client instances.

func NewConfig

func NewConfig() *Config

NewConfig returns a new Config struct with default values set.

func (*Config) Attach

func (c *Config) Attach(l EventListener) Detacher

Attach is an alias of c.Listeners.Attach.

func (*Config) AttachAudio

func (c *Config) AttachAudio(l AudioListener) Detacher

AttachAudio is an alias of c.AudioListeners.Attach.

func (*Config) AudioFrameSize

func (c *Config) AudioFrameSize() int

AudioFrameSize returns the appropriate audio frame size, based off of the audio interval.

type Conn

type Conn struct {
	sync.Mutex
	net.Conn

	MaximumPacketBytes int
	Timeout            time.Duration
	// contains filtered or unexported fields
}

Conn represents a control protocol connection to a Mumble client/server.

func NewConn

func NewConn(conn net.Conn) *Conn

NewConn creates a new Conn with the given net.Conn.

func (*Conn) ReadPacket

func (c *Conn) ReadPacket() (uint16, []byte, error)

ReadPacket reads a packet from the server. Returns the packet type, the packet data, and nil on success.

This function should only be called by a single go routine.

func (*Conn) WriteAudio

func (c *Conn) WriteAudio(format, target byte, sequence int64, final bool, data []byte, X, Y, Z *float32) error

WriteAudio writes an audio packet to the connection.

func (*Conn) WritePacket

func (c *Conn) WritePacket(ptype uint16, data []byte) error

WritePacket writes a data packet of the given type to the connection.

func (*Conn) WriteProto

func (c *Conn) WriteProto(message proto.Message) error

WriteProto writes a protocol buffer message to the connection.

type ConnectEvent

type ConnectEvent struct {
	Client         *Client
	WelcomeMessage *string
	MaximumBitrate *int
}

ConnectEvent is the event that is passed to EventListener.OnConnect.

type ContextAction

type ContextAction struct {
	// The context action type.
	Type ContextActionType
	// The name of the context action.
	Name string
	// The user-friendly description of the context action.
	Label string
	// contains filtered or unexported fields
}

ContextAction is an triggerable item that has been added by a server-side plugin.

func (*ContextAction) Trigger

func (c *ContextAction) Trigger()

Trigger will trigger the context action in the context of the server.

func (*ContextAction) TriggerChannel

func (c *ContextAction) TriggerChannel(channel *Channel)

TriggerChannel will trigger the context action in the context of the given channel.

func (*ContextAction) TriggerUser

func (c *ContextAction) TriggerUser(user *User)

TriggerUser will trigger the context action in the context of the given user.

type ContextActionChangeEvent

type ContextActionChangeEvent struct {
	Client        *Client
	Type          ContextActionChangeType
	ContextAction *ContextAction
}

ContextActionChangeEvent is the event that is passed to EventListener.OnContextActionChange.

type ContextActionChangeType

type ContextActionChangeType int

ContextActionChangeType specifies how a ContextAction changed.

type ContextActionType

type ContextActionType int

ContextActionType is a bitmask of contexts where a ContextAction can be triggered.

type ContextActions

type ContextActions map[string]*ContextAction

ContextActions is a map of ContextActions.

type Detacher

type Detacher interface {
	Detach()
}

Detacher is an interface that event listeners implement. After the Detach method is called, the listener will no longer receive events.

type DisconnectEvent

type DisconnectEvent struct {
	Client *Client
	Type   DisconnectType

	String string
}

DisconnectEvent is the event that is passed to EventListener.OnDisconnect.

type DisconnectType

type DisconnectType int

DisconnectType specifies why a Client disconnected from a server.

const (
	DisconnectError DisconnectType = iota + 1
	DisconnectKicked
	DisconnectBanned
	DisconnectUser
)

Client disconnect reasons.

func (DisconnectType) Has

func (d DisconnectType) Has(changeType DisconnectType) bool

Has returns true if the DisconnectType has changeType part of its bitmask.

type EventListener

type EventListener interface {
	OnConnect(e *ConnectEvent)
	OnDisconnect(e *DisconnectEvent)
	OnTextMessage(e *TextMessageEvent)
	OnUserChange(e *UserChangeEvent)
	OnChannelChange(e *ChannelChangeEvent)
	OnPermissionDenied(e *PermissionDeniedEvent)
	OnUserList(e *UserListEvent)
	OnACL(e *ACLEvent)
	OnBanList(e *BanListEvent)
	OnContextActionChange(e *ContextActionChangeEvent)
	OnServerConfig(e *ServerConfigEvent)
}

EventListener is the interface that must be implemented by a type if it wishes to be notified of Client events.

Listener methods are executed synchronously as event happen. They also block network reads from happening until all handlers for an event are called. Therefore, it is not recommended to do any long processing from inside of these methods.

type Listeners

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

Listeners is a list of event listeners. Each attached listener is called in sequence when a Client event is triggered.

func (*Listeners) Attach

func (e *Listeners) Attach(listener EventListener) Detacher

Attach adds a new event listener to the end of the current list of listeners.

type Message

type Message interface {
	// contains filtered or unexported methods
}

Message is data that be encoded and sent to the server. The following types implement this interface:

AccessTokens
ACL
BanList
RegisteredUsers
TextMessage
VoiceTarget

type Permission

type Permission int

Permission is a bitmask of permissions given to a certain user.

const (
	PermissionWrite Permission = 1 << iota
	PermissionTraverse
	PermissionEnter
	PermissionSpeak
	PermissionMuteDeafen
	PermissionMove
	PermissionMakeChannel
	PermissionLinkChannel
	PermissionWhisper
	PermissionTextMessage
	PermissionMakeTemporaryChannel
)

Permissions that can be applied in any channel.

const (
	PermissionKick Permission = 0x10000 << iota
	PermissionBan
	PermissionRegister
	PermissionRegisterSelf
)

Permissions that can only be applied in the root channel.

func (Permission) Has

func (p Permission) Has(o Permission) bool

Has returns true if the Permission p contains Permission o has part of its bitmask.

type PermissionDeniedEvent

type PermissionDeniedEvent struct {
	Client  *Client
	Type    PermissionDeniedType
	Channel *Channel
	User    *User

	Permission Permission
	String     string
}

PermissionDeniedEvent is the event that is passed to EventListener.OnPermissionDenied.

type PermissionDeniedType

type PermissionDeniedType int

PermissionDeniedType specifies why a Client was denied permission to perform a particular action.

func (PermissionDeniedType) Has

Has returns true if the PermissionDeniedType has changeType part of its bitmask.

type PingResponse

type PingResponse struct {
	// The address of the pinged server.
	Address *net.UDPAddr
	// The round-trip time from the client to the server.
	Ping time.Duration
	// The server's version. Only the Version field and SemanticVersion method of
	// the value will be valid.
	Version Version
	// The number users currently connected to the server.
	ConnectedUsers int
	// The maximum number of users that can connect to the server.
	MaximumUsers int
	// The maximum audio bitrate per user for the server.
	MaximumBitrate int
}

PingResponse contains information about a server that responded to a UDP ping packet.

func Ping

func Ping(address string, interval, timeout time.Duration) (*PingResponse, error)

Ping sends a UDP ping packet to the given server. If interval is positive, the packet is retransmitted at every interval.

Returns a PingResponse and nil on success. The function will return nil and an error if a valid response is not received after the given timeout.

type RegisteredUser

type RegisteredUser struct {
	// The registered user's ID.
	UserID uint32
	// The registered user's name.
	Name string
	// The last time the user was seen by the server.
	LastSeen time.Time
	// The last channel the user was seen in.
	LastChannel *Channel
	// contains filtered or unexported fields
}

RegisteredUser represents a registered user on the server.

func (*RegisteredUser) ACLUser

func (r *RegisteredUser) ACLUser() *ACLUser

ACLUser returns an ACLUser for the given registered user.

func (*RegisteredUser) Deregister

func (r *RegisteredUser) Deregister()

Deregister will remove the registered user from the server.

func (*RegisteredUser) Register

func (r *RegisteredUser) Register()

Register will keep the user registered on the server. This is only useful if Deregister() was called on the registered user.

func (*RegisteredUser) SetName

func (r *RegisteredUser) SetName(name string)

SetName sets the new name for the user.

type RegisteredUsers

type RegisteredUsers []*RegisteredUser

RegisteredUsers is a list of users who are registered on the server.

Whenever a registered user is changed, it does not come into effect until the registered user list is sent back to the server.

type RejectError

type RejectError struct {
	Type   RejectType
	Reason string
}

RejectError is returned by DialWithDialer when the server rejects the client connection.

func (RejectError) Error

func (e RejectError) Error() string

Error implements error.

type RejectType

type RejectType int

RejectType describes why a client connection was rejected by the server.

The possible reason why a client connection was rejected by the server.

type ServerConfigEvent

type ServerConfigEvent struct {
	Client *Client

	MaximumBitrate            *int
	WelcomeMessage            *string
	AllowHTML                 *bool
	MaximumMessageLength      *int
	MaximumImageMessageLength *int
	MaximumUsers              *int

	CodecAlpha       *int32
	CodecBeta        *int32
	CodecPreferAlpha *bool
	CodecOpus        *bool

	SuggestVersion    *Version
	SuggestPositional *bool
	SuggestPushToTalk *bool
}

ServerConfigEvent is the event that is passed to EventListener.OnServerConfig.

type State

type State int

State is the current state of the client's connection to the server.

const (
	// StateDisconnected means the client is no longer connected to the server.
	StateDisconnected State = iota

	// StateConnected means the client is connected to the server and is
	// syncing initial information. This is an internal state that will
	// never be returned by Client.State().
	StateConnected

	// StateSynced means the client is connected to a server and has been sent
	// the server state.
	StateSynced
)

type TextMessage

type TextMessage struct {
	// User who sent the message (can be nil).
	Sender *User
	// Users that receive the message.
	Users []*User
	// Channels that receive the message.
	Channels []*Channel
	// Channels that receive the message and send it recursively to sub-channels.
	Trees []*Channel
	// Chat message.
	Message string
}

TextMessage is a chat message that can be received from and sent to the server.

type TextMessageEvent

type TextMessageEvent struct {
	Client *Client
	TextMessage
}

TextMessageEvent is the event that is passed to EventListener.OnTextMessage.

type User

type User struct {
	// The user's unique session ID.
	Session uint32
	// The user's ID. Contains an invalid value if the user is not registered.
	UserID uint32
	// The user's name.
	Name string
	// The channel that the user is currently in.
	Channel *Channel

	// Has the user has been muted?
	Muted bool
	// Has the user been deafened?
	Deafened bool
	// Has the user been suppressed?
	Suppressed bool
	// Has the user been muted by him/herself?
	SelfMuted bool
	// Has the user been deafened by him/herself?
	SelfDeafened bool
	// Is the user a priority speaker in the channel?
	PrioritySpeaker bool
	// Is the user recording audio?
	Recording bool

	// The user's comment. Contains the empty string if the user does not have a
	// comment, or if the comment needs to be requested.
	Comment string
	// The user's comment hash. nil if User.Comment has been populated.
	CommentHash []byte
	// The hash of the user's certificate (can be empty).
	Hash string
	// The user's texture (avatar). nil if the user does not have a
	// texture, or if the texture needs to be requested.
	Texture []byte
	// The user's texture hash. nil if User.Texture has been populated.
	TextureHash []byte

	// The user's stats. Containts nil if the stats have not yet been requested.
	Stats *UserStats
	// contains filtered or unexported fields
}

User represents a user that is currently connected to the server.

func (*User) Ban

func (u *User) Ban(reason string)

Ban will ban the user from the server.

func (*User) IsRegistered

func (u *User) IsRegistered() bool

IsRegistered returns true if the user's certificate has been registered with the server. A registered user will have a valid user ID.

func (*User) Kick

func (u *User) Kick(reason string)

Kick will kick the user from the server.

func (*User) Move

func (u *User) Move(channel *Channel)

Move will move the user to the given channel.

func (*User) Register

func (u *User) Register()

Register will register the user with the server. If the client has permission to do so, the user will shortly be given a UserID.

func (*User) RequestComment

func (u *User) RequestComment()

RequestComment requests that the user's actual comment (i.e. non-hashed) be sent to the client.

func (*User) RequestStats

func (u *User) RequestStats()

RequestStats requests that the user's stats be sent to the client.

func (*User) RequestTexture

func (u *User) RequestTexture()

RequestTexture requests that the user's actual texture (i.e. non-hashed) be sent to the client.

func (*User) Send

func (u *User) Send(message string)

Send will send a text message to the user.

func (*User) SetComment

func (u *User) SetComment(comment string)

SetComment will set the user's comment to the given string. The user's comment will be erased if the comment is set to the empty string.

func (*User) SetDeafened

func (u *User) SetDeafened(muted bool)

SetDeafened sets whether the user can receive audio or not.

func (*User) SetMuted

func (u *User) SetMuted(muted bool)

SetMuted sets whether the user can transmit audio or not.

func (*User) SetPlugin

func (u *User) SetPlugin(context []byte, identity string)

SetPlugin sets the user's plugin data.

Plugins are currently only used for positional audio. Clients will receive positional audio information from other users if their plugin context is the same. The official Mumble client sets the context to:

PluginShortName + "\x00" + AdditionalContextInformation

func (*User) SetPrioritySpeaker

func (u *User) SetPrioritySpeaker(prioritySpeaker bool)

SetPrioritySpeaker sets if the user is a priority speaker in the channel.

func (*User) SetRecording

func (u *User) SetRecording(recording bool)

SetRecording sets if the user is recording audio.

func (*User) SetSelfDeafened

func (u *User) SetSelfDeafened(muted bool)

SetSelfDeafened sets whether the user can receive audio or not.

This method should only be called on Client.Self().

func (*User) SetSelfMuted

func (u *User) SetSelfMuted(muted bool)

SetSelfMuted sets whether the user can transmit audio or not.

This method should only be called on Client.Self().

func (*User) SetSuppressed

func (u *User) SetSuppressed(supressed bool)

SetSuppressed sets whether the user is suppressed by the server or not.

func (*User) SetTexture

func (u *User) SetTexture(texture []byte)

SetTexture sets the user's texture.

type UserChangeEvent

type UserChangeEvent struct {
	Client *Client
	Type   UserChangeType
	User   *User
	Actor  *User

	String string
}

UserChangeEvent is the event that is passed to EventListener.OnUserChange.

type UserChangeType

type UserChangeType int

UserChangeType is a bitmask of items that changed for a user.

const (
	UserChangeConnected UserChangeType = 1 << iota
	UserChangeDisconnected
	UserChangeKicked
	UserChangeBanned
	UserChangeRegistered
	UserChangeUnregistered
	UserChangeName
	UserChangeChannel
	UserChangeComment
	UserChangeAudio
	UserChangeTexture
	UserChangePrioritySpeaker
	UserChangeRecording
	UserChangeStats
)

User change items.

func (UserChangeType) Has

func (u UserChangeType) Has(changeType UserChangeType) bool

Has returns true if the UserChangeType has changeType part of its bitmask.

type UserListEvent

type UserListEvent struct {
	Client   *Client
	UserList RegisteredUsers
}

UserListEvent is the event that is passed to EventListener.OnUserList.

type UserStats

type UserStats struct {
	// The owner of the stats.
	User *User

	// Stats about UDP packets sent from the client.
	FromClient UserStatsUDP
	// Stats about UDP packets sent by the server.
	FromServer UserStatsUDP

	// Number of UDP packets sent by the user.
	UDPPackets uint32
	// Average UDP ping.
	UDPPingAverage float32
	// UDP ping variance.
	UDPPingVariance float32

	// Number of TCP packets sent by the user.
	TCPPackets uint32
	// Average TCP ping.
	TCPPingAverage float32
	// TCP ping variance.
	TCPPingVariance float32

	// The user's version.
	Version Version
	// When the user connected to the server.
	Connected time.Time
	// How long the user has been idle.
	Idle time.Duration
	// How much bandwidth the user is current using.
	Bandwidth int
	// The user's certificate chain.
	Certificates []*x509.Certificate
	// Does the user have a strong certificate? A strong certificate is one that
	// is not self signed, nor expired, etc.
	StrongCertificate bool
	// A list of CELT versions supported by the user's client.
	CELTVersions []int32
	// Does the user's client supports the Opus audio codec?
	Opus bool

	// The user's IP address.
	IP net.IP
}

UserStats contains additional information about a user.

type UserStatsUDP

type UserStatsUDP struct {
	Good   uint32
	Late   uint32
	Lost   uint32
	Resync uint32
}

UserStatsUDP contains stats about UDP packets that have been sent to or from the server.

type Users

type Users map[uint32]*User

Users is a map of server users.

When accessed through client.Users, it contains all users currently on the server. When accessed through a specific channel (e.g. client.Channels[0].Users), it contains only the users in the channel.

func (Users) Find

func (u Users) Find(name string) *User

Find returns the user with the given name. nil is returned if no user exists with the given name.

type Version

type Version struct {
	// The semantic version information as a single unsigned integer.
	//
	// Bits 0-15 are the major version, bits 16-23 are the minor version, and
	// bits 24-31 are the patch version.
	Version uint32
	// The name of the client.
	Release string
	// The operating system name.
	OS string
	// The operating system version.
	OSVersion string
}

Version represents a Mumble client or server version.

func (*Version) SemanticVersion

func (v *Version) SemanticVersion() (major uint16, minor, patch uint8)

SemanticVersion returns the version's semantic version components.

type VoiceTarget

type VoiceTarget struct {
	// The voice target ID. This value must be in the range [1, 30].
	ID uint32
	// contains filtered or unexported fields
}

VoiceTarget represents a set of users and/or channels that the client can whisper to.

var VoiceTargetLoopback *VoiceTarget

VoiceTargetLoopback is a special voice target which causes any audio sent to the server to be returned to the client.

Its ID should not be modified, and it does not have to to be sent to the server before use.

func (*VoiceTarget) AddChannel

func (v *VoiceTarget) AddChannel(channel *Channel, recursive, links bool, group string)

AddChannel adds a user to the voice target. If group is non-empty, only users belonging to that ACL group will be targeted.

func (*VoiceTarget) AddUser

func (v *VoiceTarget) AddUser(user *User)

AddUser adds a user to the voice target.

func (*VoiceTarget) Clear

func (v *VoiceTarget) Clear()

Clear removes all users and channels from the voice target.

Directories

Path Synopsis
Package MumbleProto is a generated protocol buffer package.
Package MumbleProto is a generated protocol buffer package.

Jump to

Keyboard shortcuts

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