mirror of
https://github.com/mumble-voip/grumble.git
synced 2025-12-22 11:01:56 -08:00
Get rid of Server's SendUDP goroutine.
This commit is contained in:
parent
875cc89b9e
commit
03932c13cf
2 changed files with 31 additions and 40 deletions
34
client.go
34
client.go
|
|
@ -298,37 +298,41 @@ func (client *Client) udpreceiver() {
|
|||
outgoing.PutBytes(buf[1 : 1+(len(buf)-1)])
|
||||
outbuf[0] = kind
|
||||
|
||||
// VoiceTarget
|
||||
if target != 0x1f {
|
||||
if target != 0x1f { // VoiceTarget
|
||||
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,
|
||||
})
|
||||
} else { // Server loopback
|
||||
buf := outbuf[0 : 1+outgoing.Size()]
|
||||
err := client.SendUDP(buf)
|
||||
if err != nil {
|
||||
client.Panicf("Unable to send UDP message: %v", err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
case mumbleproto.UDPMessagePing:
|
||||
client.server.udpsend <- &Message{
|
||||
buf: buf,
|
||||
client: client,
|
||||
err := client.SendUDP(buf)
|
||||
if err != nil {
|
||||
client.Panicf("Unable to send UDP message: %v", err.Error())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (client *Client) sendUdp(msg *Message) {
|
||||
// Send buf as a UDP message. If the client does not have
|
||||
// an established UDP connection, the datagram will be tunelled
|
||||
// through the client's control channel (TCP).
|
||||
func (client *Client) SendUDP(buf []byte) error {
|
||||
if client.udp {
|
||||
client.Printf("Sent UDP!")
|
||||
client.server.udpsend <- msg
|
||||
crypted := make([]byte, len(buf)+4)
|
||||
client.crypt.Encrypt(crypted, buf)
|
||||
return client.server.SendUDP(crypted, client.udpaddr)
|
||||
} else {
|
||||
client.sendMessage(msg.buf)
|
||||
return client.sendMessage(buf)
|
||||
}
|
||||
panic("unreachable")
|
||||
}
|
||||
|
||||
// Send a Message to the client. The Message in msg to the client's
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue