gumble: layeh.com/gumble/gumble Index | Files | Directories

package gumble

import "layeh.com/gumble/gumble"

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

Package Files

accesstokens.go acl.go audio.go audiocodec.go audiolisteners.go bans.go channel.go channels.go client.go config.go conn.go contextaction.go contextactions.go detacher.go doc.go event.go handlers.go listeners.go message.go permission.go ping.go reject.go rpwmutex.go textmessage.go user.go userlist.go users.go userstats.go version.go voicetarget.go

Constants

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

ACL group names that are built-in.

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

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

    // AudioDefaultFrameSize is the number of audio frames that should be sent in
    // a 10ms window.
    AudioDefaultFrameSize = AudioSampleRate / 100

    // AudioMaximumFrameSize is the maximum audio frame size from another user
    // that will be processed.
    AudioMaximumFrameSize = AudioSampleRate / 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
)
const ClientVersion = 1<<16 | 3<<8 | 0

ClientVersion is the protocol version that Client implements.

const DefaultPort = 64738

DefaultPort is the default port on which Mumble servers listen.

func RegisterAudioCodec Uses

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.

type ACL Uses

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 Uses

type ACLEvent struct {
    Client *Client
    ACL    *ACL
}

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

type ACLGroup Uses

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 Uses

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 Uses

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 Uses

type AccessTokens []string

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

type AudioBuffer Uses

type AudioBuffer []int16

AudioBuffer is a slice of PCM audio samples.

type AudioCodec Uses

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

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

type AudioDecoder Uses

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 Uses

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 Uses

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 Uses

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 Uses

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

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

type AudioPacket Uses

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 Uses

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

AudioStreamEvent is event that is passed to AudioListener.OnAudioStream.

type Ban Uses

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 Uses

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 Uses

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

SetAddress sets the banned IP address.

func (*Ban) SetDuration Uses

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

SetDuration changes the duration of the ban.

func (*Ban) SetMask Uses

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

SetMask sets the IP mask that the ban applies to.

func (*Ban) SetReason Uses

func (b *Ban) SetReason(reason string)

SetReason changes the reason for the ban.

func (*Ban) Unban Uses

func (b *Ban) Unban()

Unban will unban the user from the server.

type BanList Uses

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 Uses

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 Uses

type BanListEvent struct {
    Client  *Client
    BanList BanList
}

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

type Channel Uses

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 Uses

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

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

func (*Channel) Find Uses

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 Uses

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 Uses

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 Uses

func (c *Channel) Remove()

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

func (*Channel) RequestACL Uses

func (c *Channel) RequestACL()

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

func (*Channel) RequestDescription Uses

func (c *Channel) RequestDescription()

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

func (*Channel) RequestPermission Uses

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 Uses

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

Send will send a text message to the channel.

func (*Channel) SetDescription Uses

func (c *Channel) SetDescription(description string)

SetDescription will set the description of the channel.

func (*Channel) SetMaxUsers Uses

func (c *Channel) SetMaxUsers(maxUsers uint32)

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

func (*Channel) SetName Uses

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 Uses

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 Uses

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

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

type ChannelChangeType Uses

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 Uses

func (c ChannelChangeType) Has(changeType ChannelChangeType) bool

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

type Channels Uses

type Channels map[uint32]*Channel

Channels is a map of server channels.

func (Channels) Find Uses

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 Uses

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 Uses

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

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

func DialWithDialer Uses

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 Uses

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 Uses

func (c *Client) Disconnect() error

Disconnect disconnects the client from the server.

func (*Client) Do Uses

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 Uses

func (c *Client) RequestBanList()

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

func (*Client) RequestUserList Uses

func (c *Client) RequestUserList()

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

func (*Client) Send Uses

func (c *Client) Send(message Message)

Send will send a Message to the server.

func (*Client) State Uses

func (c *Client) State() State

State returns the current state of the client.

type Config Uses

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 Uses

func NewConfig() *Config

NewConfig returns a new Config struct with default values set.

func (*Config) Attach Uses

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

Attach is an alias of c.Listeners.Attach.

func (*Config) AttachAudio Uses

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

AttachAudio is an alias of c.AudioListeners.Attach.

func (*Config) AudioFrameSize Uses

func (c *Config) AudioFrameSize() int

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

type Conn Uses

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 Uses

func NewConn(conn net.Conn) *Conn

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

func (*Conn) ReadPacket Uses

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 Uses

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 Uses

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

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

func (*Conn) WriteProto Uses

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

WriteProto writes a protocol buffer message to the connection.

type ConnectEvent Uses

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

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

type ContextAction Uses

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 Uses

func (c *ContextAction) Trigger()

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

func (*ContextAction) TriggerChannel Uses

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

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

func (*ContextAction) TriggerUser Uses

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

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

type ContextActionChangeEvent Uses

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

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

type ContextActionChangeType Uses

type ContextActionChangeType int

ContextActionChangeType specifies how a ContextAction changed.

const (
    ContextActionAdd    ContextActionChangeType = ContextActionChangeType(MumbleProto.ContextActionModify_Add)
    ContextActionRemove ContextActionChangeType = ContextActionChangeType(MumbleProto.ContextActionModify_Remove)
)

ContextAction change types.

type ContextActionType Uses

type ContextActionType int

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

const (
    ContextActionServer  ContextActionType = ContextActionType(MumbleProto.ContextActionModify_Server)
    ContextActionChannel ContextActionType = ContextActionType(MumbleProto.ContextActionModify_Channel)
    ContextActionUser    ContextActionType = ContextActionType(MumbleProto.ContextActionModify_User)
)

Supported ContextAction contexts.

type ContextActions Uses

type ContextActions map[string]*ContextAction

ContextActions is a map of ContextActions.

type Detacher Uses

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 Uses

type DisconnectEvent struct {
    Client *Client
    Type   DisconnectType

    String string
}

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

type DisconnectType Uses

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 Uses

func (d DisconnectType) Has(changeType DisconnectType) bool

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

type EventListener Uses

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 Uses

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 Uses

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

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

type Message Uses

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 Uses

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 Uses

func (p Permission) Has(o Permission) bool

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

type PermissionDeniedEvent Uses

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 Uses

type PermissionDeniedType int

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

const (
    PermissionDeniedOther              PermissionDeniedType = PermissionDeniedType(MumbleProto.PermissionDenied_Text)
    PermissionDeniedPermission         PermissionDeniedType = PermissionDeniedType(MumbleProto.PermissionDenied_Permission)
    PermissionDeniedSuperUser          PermissionDeniedType = PermissionDeniedType(MumbleProto.PermissionDenied_SuperUser)
    PermissionDeniedInvalidChannelName PermissionDeniedType = PermissionDeniedType(MumbleProto.PermissionDenied_ChannelName)
    PermissionDeniedTextTooLong        PermissionDeniedType = PermissionDeniedType(MumbleProto.PermissionDenied_TextTooLong)
    PermissionDeniedTemporaryChannel   PermissionDeniedType = PermissionDeniedType(MumbleProto.PermissionDenied_TemporaryChannel)
    PermissionDeniedMissingCertificate PermissionDeniedType = PermissionDeniedType(MumbleProto.PermissionDenied_MissingCertificate)
    PermissionDeniedInvalidUserName    PermissionDeniedType = PermissionDeniedType(MumbleProto.PermissionDenied_UserName)
    PermissionDeniedChannelFull        PermissionDeniedType = PermissionDeniedType(MumbleProto.PermissionDenied_ChannelFull)
    PermissionDeniedNestingLimit       PermissionDeniedType = PermissionDeniedType(MumbleProto.PermissionDenied_NestingLimit)
)

Permission denied types.

func (PermissionDeniedType) Has Uses

func (p PermissionDeniedType) Has(changeType PermissionDeniedType) bool

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

type PingResponse Uses

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 Uses

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 Uses

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 Uses

func (r *RegisteredUser) ACLUser() *ACLUser

ACLUser returns an ACLUser for the given registered user.

func (*RegisteredUser) Deregister Uses

func (r *RegisteredUser) Deregister()

Deregister will remove the registered user from the server.

func (*RegisteredUser) Register Uses

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 Uses

func (r *RegisteredUser) SetName(name string)

SetName sets the new name for the user.

type RegisteredUsers Uses

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 Uses

type RejectError struct {
    Type   RejectType
    Reason string
}

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

func (RejectError) Error Uses

func (e RejectError) Error() string

Error implements error.

type RejectType Uses

type RejectType int

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

const (
    RejectNone              RejectType = RejectType(MumbleProto.Reject_None)
    RejectVersion           RejectType = RejectType(MumbleProto.Reject_WrongVersion)
    RejectUserName          RejectType = RejectType(MumbleProto.Reject_InvalidUsername)
    RejectUserCredentials   RejectType = RejectType(MumbleProto.Reject_WrongUserPW)
    RejectServerPassword    RejectType = RejectType(MumbleProto.Reject_WrongServerPW)
    RejectUsernameInUse     RejectType = RejectType(MumbleProto.Reject_UsernameInUse)
    RejectServerFull        RejectType = RejectType(MumbleProto.Reject_ServerFull)
    RejectNoCertificate     RejectType = RejectType(MumbleProto.Reject_NoCertificate)
    RejectAuthenticatorFail RejectType = RejectType(MumbleProto.Reject_AuthenticatorFail)
)

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

type ServerConfigEvent Uses

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 Uses

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 Uses

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 Uses

type TextMessageEvent struct {
    Client *Client
    TextMessage
}

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

type User Uses

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. Contains 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 Uses

func (u *User) Ban(reason string)

Ban will ban the user from the server.

func (*User) IsRegistered Uses

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 Uses

func (u *User) Kick(reason string)

Kick will kick the user from the server.

func (*User) Move Uses

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

Move will move the user to the given channel.

func (*User) Register Uses

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 Uses

func (u *User) RequestComment()

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

func (*User) RequestStats Uses

func (u *User) RequestStats()

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

func (*User) RequestTexture Uses

func (u *User) RequestTexture()

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

func (*User) Send Uses

func (u *User) Send(message string)

Send will send a text message to the user.

func (*User) SetComment Uses

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 Uses

func (u *User) SetDeafened(muted bool)

SetDeafened sets whether the user can receive audio or not.

func (*User) SetMuted Uses

func (u *User) SetMuted(muted bool)

SetMuted sets whether the user can transmit audio or not.

func (*User) SetPlugin Uses

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 Uses

func (u *User) SetPrioritySpeaker(prioritySpeaker bool)

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

func (*User) SetRecording Uses

func (u *User) SetRecording(recording bool)

SetRecording sets if the user is recording audio.

func (*User) SetSelfDeafened Uses

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 Uses

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 Uses

func (u *User) SetSuppressed(supressed bool)

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

func (*User) SetTexture Uses

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

SetTexture sets the user's texture.

type UserChangeEvent Uses

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 Uses

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 Uses

func (u UserChangeType) Has(changeType UserChangeType) bool

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

type UserListEvent Uses

type UserListEvent struct {
    Client   *Client
    UserList RegisteredUsers
}

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

type UserStats Uses

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 Uses

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 Uses

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 Uses

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 Uses

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 Uses

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

SemanticVersion returns the version's semantic version components.

type VoiceTarget Uses

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 = &VoiceTarget{
    ID: 31,
}

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 Uses

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 Uses

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

AddUser adds a user to the voice target.

func (*VoiceTarget) Clear Uses

func (v *VoiceTarget) Clear()

Clear removes all users and channels from the voice target.

Directories

PathSynopsis
MumbleProtoPackage MumbleProto is a generated protocol buffer package.
varint

Package gumble imports 16 packages (graph) and is imported by 26 packages. Updated 2019-09-26. Refresh now. Tools for package owners.