mirror of
https://github.com/mumble-voip/grumble.git
synced 2026-01-10 12:02:01 -08:00
Send correct channel tree. Update mumbleproto. Add comments regarding UserState permission handling.
This commit is contained in:
parent
8a836ac3af
commit
1e67afca46
5 changed files with 141 additions and 25 deletions
41
server.go
41
server.go
|
|
@ -41,7 +41,6 @@ type Server struct {
|
|||
udpconn *net.UDPConn
|
||||
|
||||
incoming chan *Message
|
||||
outgoing chan *Message
|
||||
udpsend chan *Message
|
||||
voicebroadcast chan *VoiceBroadcast
|
||||
|
||||
|
|
@ -63,7 +62,10 @@ type Server struct {
|
|||
BetaCodec int32
|
||||
PreferAlphaCodec bool
|
||||
|
||||
// Channels
|
||||
chanid int
|
||||
root *Channel
|
||||
channels map[int]*Channel
|
||||
}
|
||||
|
||||
// Allocate a new Murmur instance
|
||||
|
|
@ -78,7 +80,6 @@ func NewServer(addr string, port int) (s *Server, err os.Error) {
|
|||
s.hclients = make(map[string][]*Client)
|
||||
s.hpclients = make(map[string]*Client)
|
||||
|
||||
s.outgoing = make(chan *Message)
|
||||
s.incoming = make(chan *Message)
|
||||
s.udpsend = make(chan *Message)
|
||||
s.voicebroadcast = make(chan *VoiceBroadcast)
|
||||
|
|
@ -86,10 +87,13 @@ func NewServer(addr string, port int) (s *Server, err os.Error) {
|
|||
s.MaxBandwidth = 300000
|
||||
s.MaxUsers = 10
|
||||
|
||||
s.root = NewChannel(0, "Root")
|
||||
s.channels = make(map[int]*Channel)
|
||||
|
||||
s.root = s.NewChannel("Root")
|
||||
subChan := s.NewChannel("SubChannel")
|
||||
s.root.AddChild(subChan)
|
||||
|
||||
go s.handler()
|
||||
go s.multiplexer()
|
||||
|
||||
return
|
||||
}
|
||||
|
|
@ -152,6 +156,23 @@ func (server *Server) RemoveClient(client *Client) {
|
|||
}
|
||||
}
|
||||
|
||||
// Add a new channel to the server.
|
||||
func (server *Server) NewChannel(name string) (channel *Channel) {
|
||||
channel = NewChannel(server.chanid, name)
|
||||
server.channels[channel.Id] = channel
|
||||
server.chanid += 1
|
||||
return
|
||||
}
|
||||
|
||||
// Remove a channel from the server.
|
||||
func (server *Server) RemoveChanel(channel *Channel) {
|
||||
if (channel.Id == 0) {
|
||||
log.Printf("Attempted to remove root channel.")
|
||||
return
|
||||
}
|
||||
server.channels[channel.Id] = nil, false
|
||||
}
|
||||
|
||||
// This is the synchronous handler goroutine.
|
||||
// Important control channel messages are routed through this Goroutine
|
||||
// to keep server state synchronized.
|
||||
|
|
@ -263,7 +284,6 @@ func (server *Server) handleAuthenticate(client *Client, msg *Message) {
|
|||
|
||||
// Broadcast the the user entered a channel
|
||||
server.root.AddClient(client)
|
||||
log.Printf("server.root = %p", server.root)
|
||||
err = server.broadcastProtoMessage(MessageUserState, &mumbleproto.UserState{
|
||||
Session: proto.Uint32(client.Session),
|
||||
Name: proto.String(client.Username),
|
||||
|
|
@ -364,10 +384,8 @@ func (server *Server) sendUserList(client *Client) {
|
|||
ChannelId: proto.Uint32(0),
|
||||
})
|
||||
|
||||
log.Printf("Sent one user")
|
||||
|
||||
if err != nil {
|
||||
log.Printf("unable to send!")
|
||||
// Server panic?
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
|
@ -432,13 +450,6 @@ func (server *Server) handleIncomingMessage(client *Client, msg *Message) {
|
|||
}
|
||||
}
|
||||
|
||||
func (server *Server) multiplexer() {
|
||||
for {
|
||||
_ = <-server.outgoing
|
||||
log.Printf("recvd message to multiplex")
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Server) SetupUDP() (err os.Error) {
|
||||
addr := &net.UDPAddr{
|
||||
Port: s.port,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue