Files

132 lines
2.8 KiB
Go
Raw Permalink Normal View History

package ts3client
// EventType represents the type of event
type EventType string
const (
// Connection events
EventConnected EventType = "connected"
EventDisconnected EventType = "disconnected"
// Message events
EventMessage EventType = "message"
// Client events
EventClientEnter EventType = "client_enter"
EventClientLeft EventType = "client_left"
EventClientMoved EventType = "client_moved"
// Channel events
EventChannelList EventType = "channel_list"
// Audio events
EventAudio EventType = "audio"
EventTalkingStatus EventType = "talking_status"
// Error events
EventError EventType = "error"
// Poke events
EventPoke EventType = "poke"
)
// PokeEvent is emitted when a poke message is received
type PokeEvent struct {
SenderID uint16
SenderName string
Message string
}
// ConnectedEvent is emitted when the client successfully connects
type ConnectedEvent struct {
ClientID uint16
ServerName string
}
// DisconnectedEvent is emitted when the client disconnects
type DisconnectedEvent struct {
Reason string
}
// MessageEvent is emitted when a text message is received
type MessageEvent struct {
SenderID uint16
SenderName string
Message string
TargetMode MessageTarget // Private, Channel, or Server
}
// MessageTarget represents the target type of a message
type MessageTarget int
const (
MessageTargetPrivate MessageTarget = 1
MessageTargetChannel MessageTarget = 2
MessageTargetServer MessageTarget = 3
)
func (m MessageTarget) String() string {
switch m {
case MessageTargetPrivate:
return "Private"
case MessageTargetChannel:
return "Channel"
case MessageTargetServer:
return "Server"
default:
return "Unknown"
}
}
// ClientEnterEvent is emitted when a client enters the server
type ClientEnterEvent struct {
ClientID uint16
Nickname string
ChannelID uint64
}
// ClientLeftEvent is emitted when a client leaves the server
type ClientLeftEvent struct {
ClientID uint16
Reason string
}
// ClientMovedEvent is emitted when a client moves to a different channel
type ClientMovedEvent struct {
ClientID uint16
ChannelID uint64
}
// ChannelListEvent is emitted when the channel list is received
type ChannelListEvent struct {
Channels []*Channel
}
// AudioEvent is emitted when voice data is received
type AudioEvent struct {
SenderID uint16
Codec AudioCodec
PCM []int16 // Decoded PCM data (48kHz, mono or stereo)
Channels int // 1 for mono, 2 for stereo
}
// AudioCodec represents the audio codec type
type AudioCodec int
const (
CodecOpusVoice AudioCodec = 4
CodecOpusMusic AudioCodec = 5
)
// ErrorEvent is emitted when the server reports an error
type ErrorEvent struct {
ID string
Message string
}
// TalkingStatusEvent is emitted when a client starts or stops talking
type TalkingStatusEvent struct {
ClientID uint16
Talking bool
}