mirror of
https://github.com/mumble-voip/grumble.git
synced 2025-12-19 21:59:59 -08:00
Synchronize voice broadcast.
This commit is contained in:
parent
d7dd29b45c
commit
37262d6889
3 changed files with 40 additions and 14 deletions
14
client.go
14
client.go
|
|
@ -140,15 +140,23 @@ func (client *Client) udpreceiver() {
|
|||
|
||||
outgoing.PutUint32(client.Session)
|
||||
outgoing.PutBytes(buf[1 : 1+(len(buf)-1)])
|
||||
outbuf[0] = kind
|
||||
|
||||
// Sever loopback
|
||||
if target == 0x1f {
|
||||
outbuf[0] = kind
|
||||
// VoiceTarget
|
||||
if target != 0x1f {
|
||||
client.server.voicebroadcast <- &VoiceBroadcast{
|
||||
client: client,
|
||||
buf: outbuf[0 : 1+outgoing.Size()],
|
||||
target: target,
|
||||
}
|
||||
// Server loopback
|
||||
} else {
|
||||
client.sendUdp(&Message{
|
||||
buf: outbuf[0 : 1+outgoing.Size()],
|
||||
client: client,
|
||||
})
|
||||
}
|
||||
|
||||
case UDPMessagePing:
|
||||
client.server.udpsend <- &Message{
|
||||
buf: buf,
|
||||
|
|
|
|||
|
|
@ -65,6 +65,15 @@ type Message struct {
|
|||
address net.Addr
|
||||
}
|
||||
|
||||
type VoiceBroadcast struct {
|
||||
// The client who is performing the broadcast
|
||||
client *Client
|
||||
// The VoiceTarget identifier.
|
||||
target byte
|
||||
// The voice packet itself.
|
||||
buf []byte
|
||||
}
|
||||
|
||||
func (server *Server) handleCryptSetup(client *Client, msg *Message) {
|
||||
cs := &mumbleproto.CryptSetup{}
|
||||
err := proto.Unmarshal(msg.buf, cs)
|
||||
|
|
|
|||
31
server.go
31
server.go
|
|
@ -41,9 +41,10 @@ type Server struct {
|
|||
port int
|
||||
udpconn *net.UDPConn
|
||||
|
||||
incoming chan *Message
|
||||
outgoing chan *Message
|
||||
udpsend chan *Message
|
||||
incoming chan *Message
|
||||
outgoing chan *Message
|
||||
udpsend chan *Message
|
||||
voicebroadcast chan *VoiceBroadcast
|
||||
|
||||
// Config-related
|
||||
MaxUsers int
|
||||
|
|
@ -90,6 +91,7 @@ func NewServer(addr string, port int) (s *Server, err os.Error) {
|
|||
s.outgoing = make(chan *Message)
|
||||
s.incoming = make(chan *Message)
|
||||
s.udpsend = make(chan *Message)
|
||||
s.voicebroadcast = make(chan *VoiceBroadcast)
|
||||
|
||||
s.MaxBandwidth = 300000
|
||||
s.MaxUsers = 10
|
||||
|
|
@ -157,13 +159,20 @@ func (server *Server) RemoveClient(client *Client) {
|
|||
// to keep server state synchronized.
|
||||
func (server *Server) handler() {
|
||||
for {
|
||||
msg := <-server.incoming
|
||||
client := msg.client
|
||||
|
||||
if client.state == StateClientAuthenticated {
|
||||
server.handleIncomingMessage(client, msg)
|
||||
} else if client.state == StateClientSentVersion {
|
||||
server.handleAuthenticate(client, msg)
|
||||
select {
|
||||
// Control channel messages
|
||||
case msg := <-server.incoming:
|
||||
client := msg.client
|
||||
if client.state == StateClientAuthenticated {
|
||||
server.handleIncomingMessage(client, msg)
|
||||
} else if client.state == StateClientSentVersion {
|
||||
server.handleAuthenticate(client, msg)
|
||||
}
|
||||
// Voice broadcast
|
||||
case vb := <-server.voicebroadcast:
|
||||
log.Printf("VoiceBroadcast!")
|
||||
if vb.target == 0 {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -445,7 +454,7 @@ func (s *Server) SendUDP() {
|
|||
} else if msg.address != nil {
|
||||
s.udpconn.WriteTo(msg.buf, msg.address)
|
||||
} else {
|
||||
// Skipping
|
||||
// Skipping
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue